Weird Score Output
< Newer Topic
:: Older Topic >
Pages:<< prev 1 next >>
#1 May 7, 2011 11:48 pm
Last edited May 7, 2011 11:49 pm by Keirath
Magician
GroupMembers
Posts148
JoinedJan 24, 2008
I recently altered the classes on my MUD. After doing so, I began to receive strange output from score. I was receiving this:
Which, I knew this wasn't correct because level was still outputting the correct values. To do some debugging I added a line to do_score to make it output as follows.
The format at the beginning is nextlevel|current exp|exp needed. It is the EXACT same code as later in the output. What could possibly be causing this strange output. I've been debugging for some time and I can't figure this out.
Also: if I type save and then score the output will be correct - but only that time.
combat Level: 10 Max: 200 Exp: 40500 Next: 140733193438032 piloting Level: 1 Max: 200 Exp: 0 Next: 140733193388532 engineering Level: 1 Max: 200 Exp: 0 Next: 140733193388532
Which, I knew this wasn't correct because level was still outputting the correct values. To do some debugging I added a line to do_score to make it output as follows.
11|40500|50000) - combat Level: 10 Max: 200 Exp: 40500 Next: 140733193438032 2|0|500) - piloting Level: 1 Max: 200 Exp: 0 Next: 140733193388532 2|0|500) - engineering Level: 1 Max: 200 Exp: 0 Next: 140733193388532
The format at the beginning is nextlevel|current exp|exp needed. It is the EXACT same code as later in the output. What could possibly be causing this strange output. I've been debugging for some time and I can't figure this out.
Also: if I type save and then score the output will be correct - but only that time.
#2 May 7, 2011 11:53 pm
Magician
GroupMembers
Posts148
JoinedJan 24, 2008
Ok even more bizarre. This was the code for outputing levels:
If you change Next this:
It outputs correctly. So why would level work with the 10ld format and not score?
I am vastly confused here.
ch_printf( ch, "%-15s Level: %-3d Max: %-3d Exp: %-10ld Next: %-10ld\r\n",
If you change Next this:
ch_printf( ch, "%-15s Level: %-3d Max: %-3d Exp: %-10ld Next: %d\r\n",
It outputs correctly. So why would level work with the 10ld format and not score?
I am vastly confused here.
#3 May 8, 2011 5:27 pm
Off the Edge of the Map
GroupAdministrators
Posts1,200
JoinedMar 21, 2006
Something may be uninitialized, or initialized wrong. Or it could be attempting to put the wrong type of data in and overflowing.
#4 May 8, 2011 6:49 pm
Magician
GroupMembers
Posts148
JoinedJan 24, 2008
Why would level work and not score? When its the exact same code?
#5 May 8, 2011 10:51 pm
Off the Edge of the Map
GroupAdministrators
Posts1,200
JoinedMar 21, 2006
Like I said, something could be initializing improperly in score, that is initializing properly in level, have you double checked that everything is identical, or run it through valgrind?
#6 May 9, 2011 2:00 am
Black Hand
GroupAdministrators
Posts3,697
JoinedJan 1, 2002
Actually both functions should be using %d instead of %ld because the exp_level() function in SWR FUSS returns an integer, not a long. So do_score AND do_level are both wrong, and it's probably just one of those bizarre flukes that it hasn't been caught before.
#7 May 9, 2011 5:58 am
Magician
GroupMembers
Posts148
JoinedJan 24, 2008
It must be one of those weird fluke things. I didn't even think about the %ld. I switched both over to %d. I think I just got so frustrated that the code was the exact same that I missed that.
At one point, I made score actually call do_level and it was still messing things up. But when called alone it worked. Meh, I don't know. Not something I understand but its working now. Thanks.
At one point, I made score actually call do_level and it was still messing things up. But when called alone it worked. Meh, I don't know. Not something I understand but its working now. Thanks.
Pages:<< prev 1 next >>