Server Help

ASSS Custom Projects - <C> Lockon

Initrd.gz - Tue Feb 24, 2009 7:49 pm
Post subject: <C> Lockon
Lockon: A highly configurable turret module, similar to HS's pointdefense.

NOTE: In testing, upload will come after

Here's a complete list of things you can do with it:


It is based on HS's pointdefense.
tcsoccerman - Tue Feb 24, 2009 8:11 pm
Post subject:
Nice work, should prove useful.
Samapico - Tue Feb 24, 2009 10:50 pm
Post subject:
Quote:
I have not compiled/tested this yet


... wut?
Dr Brain - Wed Feb 25, 2009 7:33 am
Post subject:
Looking through the code I can see it won't compile.

It also looks like you don't handle attaching properly. If you attach to someone that's attached, then later they detach, you'll still be attached to the first player. That's the reason I told you not to use point defense as a reference.
Samapico - Wed Feb 25, 2009 10:59 am
Post subject:
That's also why any code should be compiled and tested, even if you're sure it works tongue.gif
Initrd.gz - Wed Feb 25, 2009 5:26 pm
Post subject:
Ok, I am sorry. I should have compiled and tested it. I just posted it when I was done with it. I will look over it again and post it when it is done. I apologize again.
Cheese - Wed Feb 25, 2009 7:00 pm
Post subject:
imagine if you bought an untested car...

dealer> look its our new car, we threw some parts in a bucket, but noone has tried to drive it yet! Starting at $11,000!
Initrd.gz - Thu Feb 26, 2009 7:01 pm
Post subject:
Looks like all the syntax errors are gone. I'm ignoring the "Dereferencing void * pointers" errors.

Dr. Brain, I am not sure what you mean by attaching.
Do you mean:
Player A is the fake.
Player B is the owner.
Player C is someone else.

Player B is attached to C, and A attaches to B, so it attaches to C.
Are you saying when B detaches from C, A is still attached? Because it looks like it should detach. icon_confused.gif
Dr Brain - Thu Feb 26, 2009 10:47 pm
Post subject:
Initrd.gz wrote:
the "Dereferencing void * pointers" errors.


That sounds bad. Cast pointers to the correct type before you deref them.

Initrd.gz wrote:
Player B is attached to C, and A attaches to B, so it attaches to C.
Are you saying when B detaches from C, A is still attached? Because it looks like it should detach. icon_confused.gif


I didn't see any code to do that, but it should be simple enough to test if it works properly.
Initrd.gz - Fri Feb 27, 2009 2:15 pm
Post subject:
Dr Brain wrote:
That sounds bad. Cast pointers to the correct type before you deref them.
Ah, so you mean instead of:
Code: Show/Hide
link->data->attribute

I should use:
Code: Show/Hide
Turret *turret = (Turret *) link->data;
turret->attribute


Ok, I'll change that...

Edit: I also get this warning when I try to compile:
Quote:
0 E:\...\lockon.c [Warning] `nul.gcda' is not a gcov data file


I am following the instructions for compiling with Dev-C++

Edit2: Changing the type works. The turret now compiles into a DLL
Samapico - Sun Mar 01, 2009 1:13 am
Post subject:
You could also simply do:

(Turret *) (link->data) ->attribute;

Though if you need to access several attributes in the next lines, it's definitely more efficient to create a pointer to link->data first
Dr Brain - Sun Mar 01, 2009 9:27 am
Post subject:
Samapico wrote:
it's definitely more efficient to create a pointer to link->data first


Any modern compiler will produce the same code regardless of which way you do it. So always pick the style that is easier to read and understand.
Initrd.gz - Sun Mar 01, 2009 3:46 pm
Post subject:
Ok, as I said, the module compiles into a DLL. However, for some reason, I cannot compile it on Linux with gcc.

Here's the command I am using, and I bet it is wrong:
Code: Show/Hide
gcc lockon.c -o lockon.so -I./include -I./

The compiler complains about stuff such as LLAlloc and even atan2 not being defined. For some reason it is not including the files.

(I just had an Idea while typing this, I'm going to compile util.c with it like Dev-C++ does)

Edit: Still doesnt work. Output:
Code: Show/Hide
$ gcc lockon.c ./main/util.c -o lockon.so -I./include -I./ -Wall
lockon.c: In function ?get_best_target?:
lockon.c:197: warning: statement with no effect
lockon.c: In function ?turret_kickoff?:
lockon.c:480: warning: suggest parentheses around assignment used as truth value
lockon.c: In function ?MM_lockon?:
lockon.c:900: warning: control reaches end of non-void function
lockon.c: At top level:
lockon.c:787: warning: ?interface? defined but not used
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
/tmp/ccPNvLFR.o: In function `fireangle':
lockon.c:(.text+0x413): undefined reference to `atan2'
/tmp/cc1H9JJR.o: In function `MPRemove':
util.c:(.text+0x1d27): undefined reference to `__pthread_register_cancel'
util.c:(.text+0x1d74): undefined reference to `__pthread_unregister_cancel'
collect2: ld returned 1 exit status

Dr Brain - Sun Mar 01, 2009 6:22 pm
Post subject:
Don't run gcc yourself on linux. Make a new directory in the asss src and put a .mk file in it, along with your source. The format for the .mk can be copied from the turf directory (it's pretty straight forward). Once you've done that:

Code: Show/Hide
make deps
make

Initrd.gz - Sun Mar 01, 2009 9:21 pm
Post subject:
For some reason I cannot compile ASSS:
-quote removed-

Edit: Installed a few packages and that part compiles, and I installed libdbd-mysql, but it seems the mysql isnt compiling:
Quote:
gcc -std=gnu99 -pipe -I. -Iinclude -I../build -D_REENTRANT -D_GNU_SOURCE -fPIC -g -Wall -I/opt/db-4.0.14/include -fPIC \
-DNODQ -DNOTREAP -DNOSTRINGCHUNK -DNOMPQUEUE -DNOMMAP \
-o ../build/dbtool ../build/statcodes.o main/util.c main/dbtool.c -L/opt/db-4.0.14/lib -Wl,-rpath,/opt/db-4.0.14/lib -ldb-4
main/dbtool.c: In function ?print_quoted?:
main/dbtool.c:177: warning: pointer targets in passing argument 1 of ?strchr? differ in signedness
main/dbtool.c:178: warning: pointer targets in passing argument 1 of ?fputs? differ in signedness
main/dbtool.c: In function ?stats_print_stats?:
main/dbtool.c:445: warning: pointer targets in passing argument 1 of ?print_quoted? differ in signedness
gcc -std=gnu99 -pipe -I. -Iinclude -I../build -D_REENTRANT -D_GNU_SOURCE -fPIC -g -Wall -I/opt/mysql/include -c -o ../build/mysql.o database/mysql.c
database/mysql.c:17:19: error: mysql.h: No such file or directory
database/mysql.c:44: error: expected ?=?, ?,?, ?;?, ?asm? or ?__attribute__? before ?*? token
database/mysql.c: In function ?do_query?:
database/mysql.c:55: warning: implicit declaration of function ?mysql_real_query?
database/mysql.c:55: error: ?mydb? undeclared (first use in this function)
database/mysql.c:55: error: (Each undeclared identifier is reported only once
database/mysql.c:55: error: for each function it appears in.)
database/mysql.c:60: warning: implicit declaration of function ?mysql_error?
database/mysql.c:60: warning: format ?%s? expects type ?char *?, but argument 3 has type ?int?
database/mysql.c:62: warning: implicit declaration of function ?mysql_errno?
database/mysql.c:66: warning: implicit declaration of function ?mysql_field_count?
database/mysql.c:74: error: ?MYSQL_RES? undeclared (first use in this function)
database/mysql.c:74: error: ?res? undeclared (first use in this function)
database/mysql.c:74: warning: implicit declaration of function ?mysql_store_result?
database/mysql.c:79: warning: format ?%s? expects type ?char *?, but argument 3 has type ?int?
database/mysql.c:89: warning: implicit declaration of function ?mysql_free_result?
database/mysql.c: In function ?close_db?:
database/mysql.c:97: warning: implicit declaration of function ?mysql_close?
database/mysql.c:97: error: ?MYSQL? undeclared (first use in this function)
database/mysql.c:97: error: expected expression before ?)? token
database/mysql.c: In function ?work_thread?:
database/mysql.c:105: error: ?mydb? undeclared (first use in this function)
database/mysql.c:105: warning: implicit declaration of function ?mysql_init?
database/mysql.c:109: warning: format ?%s? expects type ?char *?, but argument 3 has type ?int?
database/mysql.c:120: warning: implicit declaration of function ?mysql_real_connect?
database/mysql.c:120: error: ?CLIENT_COMPRESS? undeclared (first use in this function)
database/mysql.c:120: warning: comparison between pointer and integer
database/mysql.c:122: warning: format ?%s? expects type ?char *?, but argument 3 has type ?int?
database/mysql.c:138: warning: implicit declaration of function ?mysql_ping?
database/mysql.c: In function ?Query?:
database/mysql.c:217: warning: implicit declaration of function ?mysql_escape_string?
database/mysql.c: In function ?GetRowCount?:
database/mysql.c:241: warning: implicit declaration of function ?mysql_num_rows?
database/mysql.c:241: error: ?MYSQL_RES? undeclared (first use in this function)
database/mysql.c:241: error: expected expression before ?)? token
database/mysql.c: In function ?GetFieldCount?:
database/mysql.c:246: warning: implicit declaration of function ?mysql_num_fields?
database/mysql.c:246: error: ?MYSQL_RES? undeclared (first use in this function)
database/mysql.c:246: error: expected expression before ?)? token
database/mysql.c: In function ?GetRow?:
database/mysql.c:251: warning: implicit declaration of function ?mysql_fetch_row?
database/mysql.c:251: error: ?MYSQL_RES? undeclared (first use in this function)
database/mysql.c:251: error: expected expression before ?)? token
database/mysql.c: In function ?GetField?:
database/mysql.c:256: error: ?MYSQL_ROW? undeclared (first use in this function)
database/mysql.c:256: error: expected ?)? before ?row?
database/mysql.c:257: warning: control reaches end of non-void function
database/mysql.c: In function ?GetLastInsertId?:
database/mysql.c:261: warning: implicit declaration of function ?mysql_insert_id?
database/mysql.c:261: error: ?mydb? undeclared (first use in this function)
make: *** [../build/mysql.o] Error 1

Dr Brain - Sun Mar 01, 2009 9:43 pm
Post subject:
Don't compile the mysql parts then. Set
Code: Show/Hide
have_mysql := no

in system.mk.
Initrd.gz - Mon Mar 02, 2009 7:55 pm
Post subject:
K, thanks.

Gonna test once I move my server ( which requires me getting a static IP address... )
Initrd.gz - Mon May 25, 2009 10:20 pm
Post subject:
Finally fixed it so that it will compile, but I have a problem.

The module compiles, inserts, and attaches, but when I try to use the ?simpleturret command, the server crashes. Source attached.
Dr Brain - Tue May 26, 2009 6:42 am
Post subject:
If you're running on linux, the server should make a .bt file (backtrace) for every server crash. Take a look inside it. You may need to install gdb to get actual data.
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group