Welcome to the Builder Academy

Question Fight.c crash

More
19 Dec 2016 15:17 - 19 Dec 2016 19:23 #6414 by JTP
Fight.c crash was created by JTP
Added rip, kill and dt counter.

How come this line in fight.c in the pictures, some times crashes the mud ?


3rd pic is bt of core
Attachments:
Last edit: 19 Dec 2016 19:23 by JTP.

Please Log in or Create an account to join the conversation.

More
19 Dec 2016 21:38 #6415 by WhiskyTest
Replied by WhiskyTest on topic Fight.c crash
Is it because killer is NULL?.. maybe a check for that before incrementing the counters?

Please Log in or Create an account to join the conversation.

More
19 Dec 2016 21:47 #6416 by JTP
Replied by JTP on topic Fight.c crash
How can i find out if killer is NULL

And how can i code it to prevent it, if that is the case...i hate crashes

Please Log in or Create an account to join the conversation.

More
19 Dec 2016 21:54 #6417 by JTP
Replied by JTP on topic Fight.c crash
have tried killing ALOT of mobs, like 4000 and it has crashed only twice.

Please Log in or Create an account to join the conversation.

More
19 Dec 2016 21:57 - 19 Dec 2016 21:58 #6418 by WhiskyTest
Replied by WhiskyTest on topic Fight.c crash
Where the screenshots show ch = 0xa880d68 and killer = 0x0, the 0x0 means NULL or pointing to nothing.
So if you try and access values on it - like the kill counter, it will usually crash.

To prevent that you would do something like this:
Code:
if (killer && !IS_NPC(killer)) { GET_KILL_CNT(killer) += 1; }

That should be the same as writing "If killer doesn't point to NULL" eg: if (killer != NULL)
Last edit: 19 Dec 2016 21:58 by WhiskyTest.

Please Log in or Create an account to join the conversation.

More
19 Dec 2016 22:00 #6419 by JTP
Replied by JTP on topic Fight.c crash
circlemud snippet had:

__fight.c__

if (!IS_NPC(victim))
GET_RIP_CNT(victim) += 1;
if (!IS_NPC(ch))
GET_KILL_CNT(ch) += 1;

Please Log in or Create an account to join the conversation.

Time to create page: 0.250 seconds