Author |
Message |
Dr Brain Flip-flopping like a wind surfer
Age:38 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Wed Aug 03, 2011 7:30 am Post subject: |
|
|
|
|
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. _________________ Hyperspace Owner
Smong> so long as 99% deaths feel lame it will always be hyperspace to me |
|
Back to top |
|
|
Cheese Wow Cheese is so helpful!
Joined: Mar 18 2007 Posts: 1017 Offline
|
Posted: Thu Aug 04, 2011 4:23 am Post subject: |
|
|
|
|
yeah, thats what i was reading everywhere, and i couldnt figure out why my otherwise flawless code wasnt running
i figured the only way i could be getting the results i was was that i needed to manually add \0, and once i did everything started working properly...
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
edit:
i was using this for the endline business for awhile
char* nl=strchr(rbuf,'\n'); *nl=0;
and then later i had quite forgotten about something that turned to be amazing, something which i had used so often and later discarded for something better, something that works perfectly for chatnet clients in C:
STRTOK! \o/ _________________ SSC Distension Owner
SSCU Trench Wars Developer |
|
Back to top |
|
|
JoWie Server Help Squatter
Gender: Joined: Feb 25 2004 Posts: 215 Offline
|
|
Back to top |
|
|
JoWie Server Help Squatter
Gender: Joined: Feb 25 2004 Posts: 215 Offline
|
Posted: Thu Aug 04, 2011 5:59 am Post subject: |
|
|
|
|
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
|
Hint: asss has nothing to do with that, and it does not send you a \0 |
|
Back to top |
|
|
Dr Brain Flip-flopping like a wind surfer
Age:38 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Thu Aug 04, 2011 8:12 am Post subject: |
|
|
|
|
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.
Cheese, do you realize that \n means a new line? You can't have that string all one one line, because it's several lines. |
|
Back to top |
|
|
JoWie Server Help Squatter
Gender: Joined: Feb 25 2004 Posts: 215 Offline
|
Posted: Thu Aug 04, 2011 8:42 am Post subject: |
|
|
|
|
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.
|
Yea, VS does not have snprintf. But a common mistake is that people use #define snprintf _snprintf |
|
Back to top |
|
|
Dr Brain Flip-flopping like a wind surfer
Age:38 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Thu Aug 04, 2011 2:12 pm Post subject: |
|
|
|
|
Cheese has been talking about sprintf the whole time, so I don't think that's his issue. But if it is, I guess that should be a lesson about reading the documentation. |
|
Back to top |
|
|
Cheese Wow Cheese is so helpful!
Joined: Mar 18 2007 Posts: 1017 Offline
|
Posted: Mon Aug 08, 2011 10:27 pm Post subject: |
|
|
|
|
so what characters are allowed in player names?
letters, numbers, and what else? |
|
Back to top |
|
|
Cheese Wow Cheese is so helpful!
Joined: Mar 18 2007 Posts: 1017 Offline
|
Posted: Mon Aug 22, 2011 11:31 am Post subject: |
|
|
|
|
does anyone actually know how to use ToggleSet() in objects.c correctly?
I can't find source code that uses this anywhere.
I used this, which seems to work on windows, but not on linux:
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]));
|
this piece of code works on windows machines, but seems to segfault on linux machines at core/objects.c:686 |
|
Back to top |
|
|
JoWie Server Help Squatter
Gender: Joined: Feb 25 2004 Posts: 215 Offline
|
|
Back to top |
|
|
Cheese Wow Cheese is so helpful!
Joined: Mar 18 2007 Posts: 1017 Offline
|
Posted: Mon Aug 22, 2011 5:31 pm Post subject: |
|
|
|
|
but why does the prototype have char in it? :(
void (*ToggleSet)(const Target *t, short *id, char *ons, int size);
these didnt work either
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]));
|
|
|
Back to top |
|
|
JoWie Server Help Squatter
Gender: Joined: Feb 25 2004 Posts: 215 Offline
|
Posted: Mon Aug 22, 2011 6:45 pm Post subject: |
|
|
|
|
typo, i edited my post.
anyways i have used that function a lot, i've never had a crash.
line 686 tells you something went wrong much earlier on.
maybe a corrupted lvz, or you are using toggleset really early in the arena creation and the thread locking or whatever messes up |
|
Back to top |
|
|
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
Posted: Mon Aug 22, 2011 6:59 pm Post subject: |
|
|
|
|
Cheese wrote: | but why does the prototype have char in it? | ... just use a char array and put 0 or 1, don't use 'short's for the state _________________ (Insert a bunch of dead links here) |
|
Back to top |
|
|
Cheese Wow Cheese is so helpful!
Joined: Mar 18 2007 Posts: 1017 Offline
|
Posted: Tue Dec 13, 2011 2:47 pm Post subject: |
|
|
|
|
when im in another zone and i do ?find player, and that player is located in an asss zone, what file handles reporting to the biller/me the zone name? |
|
Back to top |
|
|
Dr Brain Flip-flopping like a wind surfer
Age:38 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Tue Dec 13, 2011 9:54 pm Post subject: |
|
|
|
|
I don't believe that the request goes to the target's zone at all. The biller knows where all the logged in players are, and so just supplies the name of the zone to the player issuing the ?find command. |
|
Back to top |
|
|
Cheese Wow Cheese is so helpful!
Joined: Mar 18 2007 Posts: 1017 Offline
|
Posted: Thu Dec 15, 2011 4:00 pm Post subject: |
|
|
|
|
what does objects->Image() do?
is it supposed to send a packet to the client telling it that the lvz thing is changing from one picture to a different one?
additionally, im trying to move around a lvz picture, by using
lvz->Move(&tgt,num,srcx*16,srcy*16,0,0);
lvz->Toggle(&tgt,num,1);
they appear, but they dont appear to be going anywhere... |
|
Back to top |
|
|
some resol Guest
Offline
|
Posted: Sat Dec 17, 2011 6:56 am Post subject: |
|
|
|
|
Help on '?objimage':
Targets: any
Args: <id> <image>
Change the image associated with an object id.
Object commands: ?objon ?objoff ?objset ?objmove ?objimage ?objlayer ?objtimer ?objmode ?objinfo ?objlist
Looks like it sets the image id like in a lvz, and you can also change the layer and mode and all the other stuff on the fly. |
|
Back to top |
|
|
Cheese Wow Cheese is so helpful!
Joined: Mar 18 2007 Posts: 1017 Offline
|
Posted: Tue Jan 17, 2012 1:26 am Post subject: |
|
|
|
|
so if i draw a region in one spot, and a region with the same name in another spot, is there a way to iterate through each separate box? |
|
Back to top |
|
|
Dr Brain Flip-flopping like a wind surfer
Age:38 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Tue Jan 17, 2012 6:58 am Post subject: |
|
|
|
|
There is no concept of a box, even. What are you trying to do? |
|
Back to top |
|
|
JoWie Server Help Squatter
Gender: Joined: Feb 25 2004 Posts: 215 Offline
|
Posted: Tue Jan 17, 2012 8:13 am Post subject: |
|
|
|
|
Regions are not kept in memory in such a way that makes such a thing easy.
Regions are kept in the same way as tiles:
A spare matrix that effectively means you can do tiles[tile x][tile y] = tile id;
Sparse means 0 values are not stored.
In regions it looks like
regions[tile x][tile y] = region id (u8);
If regions overlap, you get another region id. So one region may have multiple id's
So if you want to retrieve a "box" of a region, you would have to go about it in the same way as retrieving a "box" of wormholes. |
|
Back to top |
|
|
Cheese Wow Cheese is so helpful!
Joined: Mar 18 2007 Posts: 1017 Offline
|
Posted: Thu Apr 05, 2012 2:59 am Post subject: |
|
|
|
|
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
|
i think i found a bug in the flag core
so what would cause this?
only thing i can think of is that fis is bad |
|
Back to top |
|
|
Cheese Wow Cheese is so helpful!
Joined: Mar 18 2007 Posts: 1017 Offline
|
Posted: Fri Jul 26, 2013 12:13 pm Post subject: |
|
|
|
|
so i had the idea of changing the way how the asss core loads modules, in hopes to resolve circular references in interfaces
proposed process:
a MM_PRELOAD call for all modules at program start, only legal actions in this is reg_interface()
after this all modules have interfaces up
then MM_LOAD call is made
all modules then call get_interface()
downside:
all modules would have to check on each interface function if itself is loaded if a dependency is missing or noop
anyone see any problems with this?
would this work?
it seems (deceptively?) easy to implement
if this gets put in, module load order wouldnt matter at all |
|
Back to top |
|
|
Cheese Wow Cheese is so helpful!
Joined: Mar 18 2007 Posts: 1017 Offline
|
Posted: Fri Jul 26, 2013 2:59 pm Post subject: |
|
|
|
|
alternative idea:
10 pass MM_LOAD, all modules keep track of interface count, then report success in MM_AFTERLOAD, otherwise unload themselves |
|
Back to top |
|
|
Dr Brain Flip-flopping like a wind surfer
Age:38 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Sun Jul 28, 2013 7:37 am Post subject: |
|
|
|
|
Cheese wrote: | anyone see any problems with this? |
Every single module ever written would have to be modified. That's a pretty big problem. |
|
Back to top |
|
|
Cheese Wow Cheese is so helpful!
Joined: Mar 18 2007 Posts: 1017 Offline
|
Posted: Sun Jul 28, 2013 1:22 pm Post subject: |
|
|
|
|
not significant compared to a permanent future of having to deal with shit |
|
Back to top |
|
|
|