Code: Show/Hide local void Damaged(Arena *a, Player *p, struct S2CWatchDamage *damage, int count) { chat->SendMessage(p,"You took %i damage. c=%i",damage->damage->damage,count); chat->SendArenaMessage(ALLARENAS,"someone took dmg"); return; } |
Code: Show/Hide mm->RegCallback(CB_PLAYERDAMAGE,Damaged,ALLARENAS); |
Cheese wrote: | ||
with this code:
and this call:
why does nothing happen with a successful compile? |
Cheese wrote: |
why does it seem that arena->playing and arena->total give the same number, even while 2 are in ships and 1 in spec? |
Cheese wrote: |
why is there an arena passed to the export function, when it seems that any attempt to get information from the struct fails, or even worse, crashes the server on load? |
Cheese wrote: |
is it possible to get an as3 server to listen on an external chat and respond to words/commands? |
Cheese wrote: |
where are my periodic rewards? |
Cheese wrote: |
is it possible to create a non eLVL region? |
Cheese wrote: |
why is http://asss.yi.org/ down 95% of the time? |
Cheese wrote: |
how can i detect a ball or flag win? |
Cheese wrote: |
why does as3 have ?flagreset and not ?ballreset? |
Quote: | ||
Cheese wrote:
is it possible to create a non eLVL region?
|
Quote: |
Quote:
Cheese wrote: is it possible to create a non eLVL region? Quote: Is it possible to create a non-beef hamburger? Not while still remaining edible. LOL |
Dr Brain wrote: |
Which export function are you talking about? |
Code: Show/Hide //what does this do? EXPORT const char info_hs_fuschia[] = "v1.0 Dr Brain <drbrain@gmail.com>"; //why is *arena there? EXPORT int MM_hs_fuschia(int action, Imodman *_mm, Arena *arena) |
Dr Brain wrote: |
Callbacks. |
Dr Brain wrote: |
Because no damage watching is enabled. |
Cheese wrote: |
arena->playing and arena->total give the same number |
Dr Brain wrote: |
In the periodic points module. |
Cheese wrote: |
^export functions |
Cheese wrote: |
***edit: also, why am i getting linker undefined reference errors to LLInit+LLAdd+LLEmpty? |
Cheese wrote: | ||
which, i cant seem to find them... |
Cheese wrote: |
Cheese> ?man watchdamage
Sorry, I don't know anything about ?watchdamage how might i remedy this? didnt find a commented out module that looked suspicious... |
Cheese wrote: | ||
does this mean i have to use GetPoints() with SetTimer() because theres no callback? =( also, where can i find a correct usage of SetTimer(), getting compile warnings for not using pointers correctly, its annoying the hell out of me... |
Dr Brain wrote: |
CB_WARZONEWIN CB_GOAL |
Cheese wrote: |
will an attached module work if it isnt in modules.conf? |
Cheese wrote: | |
why does pymod give this console error when loading?
|
Cheese wrote: |
why can i load <py> fg_wz, but <py> fg_turf will crash the server? |
Dr Brain wrote: |
In the periodic points module. |
Dr Brain wrote: |
look at where you found the original callback for the damage |
Dr Brain wrote: |
That's how I started doing asss programming |
Cheese wrote: |
i was using CB_FLAGRESET,
reset cmd = -1 win = 0+ how is CB_WARZONEWIN different? |
Cheese wrote: |
and how can CB_GOAL detect when the game is won and reset? |
Code: Show/Hide chat->SendArenaSoundMessage(arena, SOUND_DING, "Soccer game over.");
RewardPoints(arena, freq); DO_CBS(CB_GOALWIN, arena, GoalWinFunc, (arena, freq, RewardPoints)); |
Code: Show/Hide /* dist: public */ #ifndef __POINTS_GOAL_H #define __POINTS_GOAL_H #define CB_GOALWIN "goalwin" typedef void (*GoalWinFunc)(Arena *a, int freq, int points); /* called after a ball game is won */ #endif |
Cheese wrote: |
also, is there some sort of command listing command that i dont know about yet?
if not, i will make one |
Code: Show/Hide @echo off
ECHO starting asss... SET PYTHONPATH=C:\Python25\Lib GOTO START :START bin\asss.exe IF ERRORLEVEL 5 GOTO MODLOAD IF ERRORLEVEL 4 GOTO MODCONF IF ERRORLEVEL 3 GOTO OOM IF ERRORLEVEL 2 GOTO GENERAL IF ERRORLEVEL 1 GOTO RECYCLE IF ERRORLEVEL 0 GOTO SHUTDOWN ECHO unknown exit code: %ERRORLEVEL%. GOTO END :SHUTDOWN ECHO asss exited with shutdown. GOTO END :RECYCLE ECHO asss exited with recycle. GOTO START :GENERAL ECHO asss exited with general error. GOTO END :OOM ECHO asss out of memory. restarting. GOTO START :MODCONF ECHO asss cannot start. bad modules.conf. GOTO END :MODLOAD ECHO asss cannot start. error loading modules. GOTO END :END |
Code: Show/Hide [Listen1] Port=1400 ;AllowCont=1 ;AllowVIE=0 ;BindAddress= ;ConnectAs= [Listen2] Port=1450 ConnectAs=distension [Directory] Name=CZ ASSS Description=CZ ASSS: A test zone. Password=#$(^@# Server1=10.0.0.3 [Directory-distension] Name=CZ Distension Description=CZ Distension: Development zone for the TW RPG. Password=$@(^$@# [Redirects] tw=66.36.241.110:5400:#cheez |
Cheese wrote: |
will an attached module work if it isnt in modules.conf? |
Cheese wrote: |
why can i load <py> fg_wz, but <py> fg_turf will crash the server? |
Cheese wrote: | ||
does that mean that its supposed to work automatically if the .cfg for the arena is correct? because it isnt... |
Cheese wrote: |
why is the standard SendAnyMessage() sent to a linked list?
why not to a player or arena? |
Cheese wrote: |
thanks, and might that be causing <py> fg_turf to crash the server as well?
pretty sure i dont have python anywhere on the computer... but at the same time, why does <py> fg_wz work then? |
Hakaku wrote: |
look at chat.h for an entire listing with explanations on usage.
|
Hakaku wrote: |
A lot of the necessary settings aren't available via esc+c |
userguide.pdf wrote: | ||
|
Hakaku wrote: |
(probably should mention this in your checklist, since it really is a problem) |
Quote: |
if its client side, it will never get fixed... |
Cheese wrote: |
but in the second 'zone' it does NOT take me to an arena, but to pub like the other... |
Cheese wrote: |
i was under the impression that one 'zone' could take you to pub, while the second 'zone' could take you to a specific subarena.
i have multipub disabled. |
Cheese wrote: |
since multipub is now enabled, will the main pub overflow into 2 now? |
Cheese wrote: |
and if i have the 2nd zone set to enter into 'arena' why do you get placed into 'arena1',
and is there a way to go arena, arena2, arena3, etc and NOT arena1, arena2, arena3, etc |
Cheese wrote: |
ap_multipub.c is part of the core, would making a module overwrite its actions? |
Cheese wrote: |
also, looking through the src, i cant seem to find how asss handles setting doors...
aka, it doesnt use cfg DoorMode, theres no game->door(250);, etc or did i miss something...? |
Cheese wrote: |
also, why does adding dmg watch crash my module?
just one line, wd->ModuleWatch(p,1); can crash it... no compilation issues. |
Cheese wrote: |
where can i find the code that deals with *timer and ?time?
|
Code: Show/Hide cd asss/src grep Ctime */*.c |
Cheese wrote: |
will cfg->SetInt(GLOBAL,"door","doormode",0,"open sesame!",1); then cfg->FlushDirtyValues(); make all the doors open for players? |
Cheese wrote: |
how would i ensure they get one?
when are they sent? |
Cheese wrote: |
also, windows has a grep, i use it a LOT |
Cheese wrote: |
how has the asss core gotten this far without an easy way to change door state?
its used a lot, and accordingly there should be a game->Door(255) or SOMETHING, ffs |
Dr Brain wrote: |
Doing that would give people the false impression that it's a good idea. Did you not read what I said about sending lots of clientset packets? It's bad. |
Code: Show/Hide /* this isn't for general use */ #define CB_REWRITECOMMAND "rewritecommand" typedef void (*CommandRewriterFunc)(int initial, char *buf, int len); |
Code: Show/Hide static void FlagGameInit(Arena *arena) { flagcore->SetCarryMode(arena, CARRY_ALL); flagcore->ReserveFlags(arena, 15); } static void FlagGameFlagTouch(Arena *arena, Player *p, int fid) { // ... } static void FlagGameCleanup(Arena *arena, int fid, int reason, Player *oldcarrier, int oldfreq) { // ... } static void FlagGainCB(Arena *arena, Player *p, int fid, int how) { // ... } static void FlagLostCB(Arena *arena, Player *p, int fid, int how) { // ... } static void FlagOnMapCB(Arena *arena, int fid, int x, int y, int freq) { // ... } static void FlagResetCB(Arena *arena, int freq, int points) { // ... } static Iflaggame flaggame = { INTERFACE_HEAD_INIT(I_FLAGGAME, "myflaggame") FlagGameInit, FlagGameFlagTouch, FlagGameCleanup }; EXPORT int MM_bla(int action, Imodman *mm_, Arena *arena) { // ... else if (action == MM_ATTACH) { mm->RegInterface(&flaggame, arena); mm->RegCallback(CB_FLAGGAIN, FlagGainCB, arena); mm->RegCallback(CB_FLAGLOST, FlagLostCB, arena); mm->RegCallback(CB_FLAGONMAP, FlagOnMapCB, arena); mm->RegCallback(CB_FLAGRESET, FlagResetCB, arena); } else if (action == MM_DETACH) { if (mm->UnregInterface(&flaggame, arena)) return MM_FAIL; mm->UnregCallback(CB_FLAGGAIN, FlagGainCB, arena); mm->UnregCallback(CB_FLAGLOST, FlagLostCB, arena); mm->UnregCallback(CB_FLAGONMAP, FlagOnMapCB, arena); mm->UnregCallback(CB_FLAGRESET, FlagResetCB, arena); } } |
Cheese wrote: |
and if that is true too, then couldnt we completely bypass the 4mb file transfer limit by sending the players requesting dl to a fake arena, then build the arena file structure, then send them to the real arena? :O |
L.C. wrote: |
[..]
That's assuming there isn't a limit imposed on those two functions. If there is, and it happens to be the same limit, at least you can do up to 8 MB. :p |
Dr Brain wrote: |
IIRC, the incoming file name length is limited to 15 chars. |
Code: Show/Hide Assertion failed: ad->fis[i].state == FI_ONMAP, file core/flagcore.c, line 132 This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. asss out of memory. restarting. |
Quote: |
In computer programming, an assertion is a predicate (i.e., a true?false statement) placed in a program to indicate that the developer thinks that the predicate is always true at that place. |
Cheese wrote: |
i remember reading about all the possible weapon packet types/values on a site or possibly src file somewhere that listed all the types and their alternate values somewhere. (bomb + alt = mine)
does anyone know of something like that? also, im really only interested in the special cases, if that helps (burst alt? decoy alt? thor alt?) |
Mine GO BOOM wrote: |
By the data format alone, it supports upto 32,768 numbers (everything between 0 and 32,767). As if you should ever use that many without making Continuum use up 500meg of RAM, I'd suggest not. |
Cheese wrote: |
what is the possible range for *objon?
i would guess its a power of 2, and i know its over 256... and what is the point of failure? does the lvz builder break first or the objon cmd? PS: also, it looks like theres a 256 object max? edit: found it. [..] so its (2^16)/2 thats like a signed short int, right? |
JoWie wrote: |
I thought it was 255 max images per lvz file and 256 max total |
Code: Show/Hide DO_CBS(CB_X,a,xFunc,(a,p,freq)); |
Code: Show/Hide #define CB_X "x" typedef void (*xFunc)(Arena *a, Player *p, int freq); |
Code: Show/Hide #define hmm(A,B) do { A *= 4; B += 6 } while(0) int a = 5, b = 7; if (1) hmm(a, b); |
Code: Show/Hide Player *pstats[10]; //lock FOR_EACH_PLAYER_IN_ARENA(p,a) { //stuff pstats[0]=p; } //unlock //more stuff pstats[0]->name |
Code: Show/Hide Player pstats[10]; //lock FOR_EACH_PLAYER_IN_ARENA(p,a) { //stuff pstats[0]=*p; } //unlock //more stuff pstats[0].name |
Cheese wrote: |
why does
int totalrp[2]; lm->Log(L_DRIVEL,"0a 0=%i 1=%i",totalrp[0],totalrp[1]); output D 0a 0=2293240 1=4207083 what the hell is going on? its only 2 lines of code, nothing else |
Quote: |
from autoturret.c |
Quote: |
int bd < 1024*16 |
Quote: |
i cant figure out why |
Cheese wrote: |
what metric is the recharge on ships based off of? |
JoWie wrote: |
CB_NEWPLAYER is right after a player gets allocated and right before the freeing |
Arnk Kilo Dylie wrote: |
When you call EndFaked you should no longer be keeping the pointer anywhere. |
Code: Show/Hide //dt=change in time //tp=target pos //md=fake pos while(dt) { dt--; int dx=tp->position.x - md->pos.x; int dy=tp->position.y - md->pos.y; md->pos.xspeed+=(dx > md->thr) ? md->thr : dx; md->pos.yspeed+=(dy > md->thr) ? md->thr : dy; if(md->pos.xspeed > md->spd) md->pos.xspeed=md->spd; if(md->pos.xspeed < -md->spd) md->pos.xspeed=-md->spd; if(md->pos.yspeed > md->spd) md->pos.yspeed=md->spd; if(md->pos.yspeed < -md->spd) md->pos.yspeed=-md->spd; md->pos.x+=md->pos.xspeed; md->pos.y+=md->pos.yspeed; } |
Code: Show/Hide if(dx == 0) dx++; double dir=atan(dy/dx); md->pos.xspeed+=md->thr*sin(dir); md->pos.yspeed-=md->thr*cos(dir); int spd=sqrt(pow(md->pos.xspeed,2)+pow(md->pos.yspeed,2)); if(spd > md->spd) { int excess=spd-md->spd; md->pos.xspeed-=excess*sin(dir); md->pos.yspeed+=excess*cos(dir); } |
Code: Show/Hide dt=TICK_DIFF(now,md->lastmove); ... while(dt) { dt--; int dx=tp->position.x - md->pos.x; int dy=tp->position.y - md->pos.y; if(dx == 0) dx++; double dir=atan(dy/dx); //<----------------- md->pos.xspeed+=md->thr*sin(dir); md->pos.yspeed-=md->thr*cos(dir); int spd=sqrt(pow(md->pos.xspeed,2)+pow(md->pos.yspeed,2)); if(spd > md->spd) { int excess=spd-md->spd; md->pos.xspeed-=excess*sin(dir); md->pos.yspeed+=excess*cos(dir); } md->pos.x+=md->pos.xspeed; md->pos.y+=md->pos.yspeed; } |
Code: Show/Hide #define STATE_A 1 #define STATE_B 2 #define STATE_C 4 #define STATE_D 8 int oldstate=0; setflags(int newflags, BOOL value) //falue is true to add flags, false to remove { if(!value) newflags=!newflags; if(!oldstate & state) oldstate+=state; } |
Code: Show/Hide setflag(int oldflag, int newflag) { oldstate |= newflag; //this is equivalent to: oldstate = oldsate|newflag; } clearflag(int oldflag, int newflag) { oldstate = oldstate & (~newflag); } |
Code: Show/Hide setflags(int newflags, BOOL value) //falue is true to add flags, false to remove { if(value) oldstate |= newflags; //or 'oldstate = (oldstate | newflags);' else oldstate = (oldstate & (~newflags)); } |
Dr Brain wrote: |
The "!" is a logical not, you want the "~" for bitwise not.
|
Samapico wrote: |
And I suggest you define your flags in a typedef enum |
Arnk Kilo Dylie wrote: |
LLEnumNC(list, afree); for compile-warning reducing goodness. |
Cheese wrote: |
so if it warns u, just cast it and tell it to stfu |
Dr Brain wrote: |
If you've got to cast something, you're probably doing crazy stuff (like implementing OO in a non-OO language). |
Cheese wrote: |
is there another way to get it there? |
Cheese wrote: |
and i dont see where the ship names (the top part) is used, where might that be used? |
Code: Show/Hide /asss/scripts$ ./run-asss *** ASSS started asss 1.5.0 built at May 26 2011 20:57:38 Loading modules... I <cmod> loading C module 'unixsignal' from 'internal' I <cmod> loading C module 'deadlock' from 'internal' I <cmod> loading C module 'prng' from 'internal' I <cmod> loading C module 'logman' from 'internal' I <cmod> loading C module 'mainloop' from 'internal' I <cmod> loading C module 'config' from 'internal' I <cmod> loading C module 'log_file' from 'internal' I <cmod> loading C module 'playerdata' from 'internal' I <cmod> loading C module 'lagdata' from 'internal' I <cmod> loading C module 'bw_default' from 'internal' I <cmod> loading C module 'net' from 'internal' I <cmod> loading C module 'chatnet' from 'internal' I <cmod> loading C module 'arenaman' from 'internal' I <cmod> loading C module 'mapdata' from 'internal' I <cmod> loading C module 'capman' from 'internal' W <config> Can't find file for arena '(null)', name 'groupdef/mod.txt' W <config> Can't find file for arena '(null)', name 'groupdef/smod.txt' W <config> Can't find file for arena '(null)', name 'groupdef/sysop.txt' W <config> Can't find file for arena '(null)', name 'groupdef/sysop.txt' W <config> Can't find file for arena '(null)', name 'groupdef/mine.txt' W <config> Can't find file for arena '(null)', name 'groupdef/default.txt' I <cmod> loading C module 'mapnewsdl' from 'internal' I <cmod> loading C module 'core' from 'internal' I <cmod> loading C module 'clientset' from 'internal' I <cmod> loading C module 'persist' from 'scoring' db_env_create: Permission denied E <cmod> error loading module 'persist' Unrecoverable error (5): Error in loading module 'scoring:persist' *** ASSS exited: Error loading modules |
Code: Show/Hide E <cmod> can't find file: security Unrecoverable error (5): Error in loading module 'security:security' *** ASSS exited: Error loading modules |
Code: Show/Hide I <cmod> loading C module 'capman' from 'internal' W <config> Can't find file for arena '(null)', name 'groupdef/mod.txt' W <config> Can't find file for arena '(null)', name 'groupdef/smod.txt' W <config> Can't find file for arena '(null)', name 'groupdef/sysop.txt' W <config> Can't find file for arena '(null)', name 'groupdef/sysop.txt' W <config> Can't find file for arena '(null)', name 'groupdef/mine.txt' W <config> Can't find file for arena '(null)', name 'groupdef/default.txt' I <cmod> loading C module 'mapnewsdl' from 'internal' |
Code: Show/Hide /asss$ ls arenas bin build clients conf data dataOLD dist doc log lvz maps news.txt scripts scrty scrty1 src test tmp |
Code: Show/Hide If installed, you should find the locations of your Python, MySQL, and other dependencies before you begin. |
Code: Show/Hide First, you need to clone the files from the ASSS repository. hg clone https://bitbucket.org/grelminar/asss ../asss |
Code: Show/Hide Then, after the files have transferred, you will need to build the program files from source code. cd src mv system.mk.dist system.mk |
Code: Show/Hide If you have Python or MySQL installed, you must point the compiler at them. vim system.mk |
Code: Show/Hide Find the following lines and change them to their respective locations MYSQL_HOME = /opt/mysql PYTHON_HOME = /usr |
Code: Show/Hide If you do NOT have Python or MySQL installed, you must comment out the following lines, by adding a # in front of them: have_bdb := yes have_mysql := yes have_python := yes |
Code: Show/Hide Then build the files. make |
Code: Show/Hide You will then get to watch a nice wall of spam. Because the developers wanted to be able to update everything on a server already running ASSS, you must now copy all the files into their proper locations. cd dist mv arenas ../arenas mv clients ../clients mv conf ../conf mv maps ../maps mv news.txt ../news.txt mv scrty ../scrty mv scrty1 ../scrty1 |
Code: Show/Hide Since the security module does not exist yet, you will have to go into modules.conf comment out security:security comment out security:enc_cont uncomment enc_null |
Code: Show/Hide Since the scoring module apparently does not exist yet, you will have to copy scoring.so from a preexisting server into your bin directory. new server owners are screwed all scoring:* are already commented out hope you don't like points |
Code: Show/Hide Update ASSSHOME with the path to your ASSS root directory. cd scripts vim run-asss |
Code: Show/Hide For ease of access, you may want to move the run-asss script to the root directory. mv run-asss ../run [optional, update ASSSHOME] |
Code: Show/Hide debug := yes opt := no prof := no link_db_statically := no symlink_bins := yes have_bdb := yes have_mysql := yes have_python := yes ASSSHOME = .. BINDIR = $(ASSSHOME)/bin BUILDDIR = $(ASSSHOME)/build SCRIPTS = $(ASSSHOME)/scripts PYMOD_HEADERS = $(wildcard */*.h) INSTALL := install LN := ln PYTHON := python REALPATH := readlink -f DB_HOME = /usr DB_INC = $(DB_HOME)/include DB_LIB = $(DB_HOME)/lib DB_CFLAGS = -I$(DB_INC) ifneq ($(link_db_statically),yes) DB_LDFLAGS = -L$(DB_LIB) -Wl,-rpath,$(DB_LIB) -ldb-4 else DB_LDFLAGS = $(DB_LIB)/libdb.a endif MYSQL_HOME = /usr MYSQL_INC = /usr/include/mysql MYSQL_LIB = /usr/lib/mysql MYSQL_CFLAGS = -I$(MYSQL_INC) MYSQL_LDFLAGS = -L$(MYSQL_LIB) -Wl,-rpath,$(MYSQL_LIB) -lmysqlclient_r PYTHON_HOME = /usr PYTHON_VERSION = 2.6 PYTHON_INC = $(PYTHON_HOME)/include/python$(PYTHON_VERSION) PYTHON_LIB = $(PYTHON_HOME)/lib/python$(PYTHON_VERSION) PYTHON_CFLAGS = -I$(PYTHON_INC) PYTHON_LDFLAGS = -L$(PYTHON_LIB)/config -lpython$(PYTHON_VERSION) $(UTIL_LIB) -lm |
Code: Show/Hide ASSSHOME=$HOME/zone |
Dr Brain wrote: |
Either you missed a compile error, or you intentionally disabled the scoring by disabling have_bdb |
Code: Show/Hide I <cmod> loading C module 'security' from 'security' Illegal instruction *** ASSS exited: Got signal 4, restarting... |
Code: Show/Hide I <cmod> loading C module 'security' from 'security' E <cmod> error in dlopen: asss/bin/security.so: wrong ELF class: ELFCLASS32 Unrecoverable error (5): Error in loading module 'security:security' *** ASSS exited: Error loading modules |
Code: Show/Hide sudo chown youruser:youruser -R ~/zone find ~/zone -type d -exec chmod u=rwx,go=rx {} \; find ~/zone -type f -exec chmod u=rw,go=r {} \; chmod u+x ~/zone/bin/asss chmod u+x ~/zone/run-asss |
Cheese wrote: |
however, the zone still cant find the maps, which i want to keep in asss/maps, and in each arena.conf i have general:map=maps/map.lvl, but it cant find the map despite it being in the proper location |
Cheese wrote: |
also @ dr brain:
it seems that the auto build script makefile thingy automatically made everything in asss/bin into a symlink to asss/build and asss/src/py or something |
Code: Show/Hide #3 0x000000000045f807 in handle_sigsegv () No symbol table info available. #4 <signal handler called> No symbol table info available. #5 0x000000000041f1b1 in lookup_sparse () No symbol table info available. #6 0x0000000000420e52 in FindEmptyTileNear () No symbol table info available. #7 0x00007f93b402a74d in newflag () from asss/bin/flags.so |
Code: Show/Hide local Imapdata *map; map->FindEmptyTileNear(a,&fi.x,&fi.y); |
Code: Show/Hide FlagInfo fi; fi.x=x; fi.y=y; if(old) flag->GetFlags(a,fid,&fi,1); fi.state=FI_ONMAP; if(carried) fi.state=FI_CARRIED; fi.freq=freq; fi.carrier=p; //printf: a=31305840 &fi.x=-1619391424 &fi.y=-1619391420 fi.X=147456 fi.Y=0 x=-1 y=-1 map->FindEmptyTileNear(a,&fi.x,&fi.y); |
Cheese wrote: |
question 2:
so im trying to write a batch file for windows is there any way to get the directory of the file which has been dragged onto it? like how do i take the file.txt off of /a/b/c/file.txt? |
Cheese wrote: |
clearly you didnt read the third line |
Dr Brain wrote: |
sprintf in C is guaranteed to print a null character. Same with snprintf.
EDIT: at least all the documentation I can find online backs this up. If you can find documentation that doesn't, I'd be very interested to see it. |
Cheese wrote: |
also: so why does chatnet send Player1\nPlayer2\n\0 on 1 line instead of one per line when you enter an arena? thats pretty dumb |
Dr Brain wrote: |
Yes, sprintf is guaranteed to print a null character. _snprintf (notice the n) is a MS thing and doesn't conform to the standard snprintf which does always print a null.
|
Code: Show/Hide Target t; t.type=T_ARENA; t.u.arena=a; int top0=0; int top1=0; int topempty=0; int bottom0=0; int bottom1=0; int bottomempty=0; int hold0=0; int hold1=0; short ids[]={LVZ_TOPBASE_ARMY0,LVZ_TOPBASE_ARMY1,LVZ_TOPBASE_EMPTY,LVZ_BOTBASE_ARMY0,LVZ_BOTBASE_ARMY1,LVZ_BOTBASE_EMPTY,LVZ_SECTOR_HOLD_FREQ0,LVZ_SECTOR_HOLD_FREQ1}; char states[]={top0,top1,topempty,bottom0,bottom1,bottomempty,hold0,hold1}; obj->ToggleSet(&t,ids,states,sizeof(ids)/sizeof(ids[0])); |
Code: Show/Hide short ids[64]; char ons[64]; ids[0] = 5000; ons[0] = 1; ids[1] = 5001; ons[1] = 1; ids[2] = 5002; ons[2] = 1; ids[3] = 5003; ons[3] = 1; objs->ToggleSet(&tgt, ids, ons, 4); |
Code: Show/Hide short ids[8]; ids[0]=LVZ_TOPBASE_ARMY0; ids[1]=LVZ_TOPBASE_ARMY1; ids[2]=LVZ_TOPBASE_EMPTY; ids[3]=LVZ_BOTBASE_ARMY0; ids[4]=LVZ_BOTBASE_ARMY1; ids[5]=LVZ_BOTBASE_EMPTY; ids[6]=LVZ_SECTOR_HOLD_FREQ0; ids[7]=LVZ_SECTOR_HOLD_FREQ1; short states[8]; states[0]=top0; states[1]=top1; states[2]=topempty; states[3]=bottom0; states[4]=bottom1; states[5]=bottomempty; states[6]=hold0; states[7]=hold1; obj->ToggleSet(&t,ids,states,8); // short ids[]={LVZ_TOPBASE_ARMY0,LVZ_TOPBASE_ARMY1,LVZ_TOPBASE_EMPTY,LVZ_BOTBASE_ARMY0,LVZ_BOTBASE_ARMY1,LVZ_BOTBASE_EMPTY,LVZ_SECTOR_HOLD_FREQ0,LVZ_SECTOR_HOLD_FREQ1}; // short states[]={top0,top1,topempty,bottom0,bottom1,bottomempty,hold0,hold1}; // obj->ToggleSet(&t,ids,states,sizeof(ids)/sizeof(ids[0])); |
Cheese wrote: |
but why does the prototype have char in it? ![]() |
Code: Show/Hide asss 1.5.0 built at Jul 20 2011 21:20:59 Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7ffff1b71700 (LWP 28580)] 0x00000000004358fa in cleanup (p=0x6ede70, a=0x6ef680, reason=2) at core/flagcore.c:105 105 if (ad->fis[i].state == FI_CARRIED && (gdb) l 100 adata *ad = P_ARENA_DATA(a, adkey); 101 102 LOCK(); 103 ad->during_cleanup = TRUE; 104 for (i = 0; i < ad->count; i++) 105 if (ad->fis[i].state == FI_CARRIED && 106 ad->fis[i].carrier == p) 107 { 108 ad->fis[i].state = FI_NONE; 109 ad->fis[i].carrier = NULL; (gdb) (gdb) bt #0 0x00000000004358fa in cleanup (p=0x6ede70, a=0x6ef680, reason=2) at core/flagcore.c:105 #1 0x0000000000436d36 in shipfreqchange (p=0x6ede70, newship=8, oldship=0, newfreq=9999, oldfreq=0) at core/flagcore.c:469 #2 0x000000000042e742 in SetShipAndFreq (p=0x6ede70, ship=8, freq=9999) at core/game.c:958 |
Cheese wrote: |
anyone see any problems with this? |