Welcome to the Builder Academy

Question Mobile Race Snippet

More
29 Aug 2014 05:23 #5017 by Liko
Mobile Race Snippet was created by Liko
Hello,
I have developed a snippet that allows builders to set mobiles races thru medit. The snippet works for me because I have no mobs, but when I try to test it on tbaMUD, I am met with this error:
Code:
Aug 28 22:32:36 :: SYSERR: Format error in last line of mob #0 ...expecting line of form '# # # #'

Here is the code:
db.c
Code:
if (sscanf(line, " %d %d %d %d ", t, t + 1, t + 2, t + 3) != 4) { log("SYSERR: Format error in last line of mob #%d\n" "...expecting line of form '# # # #'", nr); exit(1); } GET_POS(mob_proto + i) = t[0]; GET_DEFAULT_POS(mob_proto + i) = t[1]; GET_SEX(mob_proto + i) = t[2]; GET_CLASS(mob_proto + i) = t[3];

I edited the ones in gnemob.c and genolc.c

I seem to need to make a check that if it is missing the 0 in the line it adds it. Does anyone know how to do this? I really want to release this snippet. It worked perfect in my mud.

Randian(0.0.0)
Owner/Developer

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

More
30 Aug 2014 12:07 #5022 by WhiskyTest
Replied by WhiskyTest on topic Mobile Race Snippet
It depends how the new code is writing the extra race information, but assuming it is adding on one additional value to this line you would write something like:
Code:
if (sscanf(line, " %d %d %d %d %d ", t, t + 1, t + 2, t + 3, t + 4) != 5) { log("SYSERR: Format error in last line of mob #%d, converting..\n" "...expecting line of form '# # # # #'", nr); //exit(1); comment this out until you have saved all the mobs with the new format t[4] = 0; // arbitrarily set a default race if none was scanned above } GET_POS(mob_proto + i) = t[0]; GET_DEFAULT_POS(mob_proto + i) = t[1]; GET_SEX(mob_proto + i) = t[2]; GET_CLASS(mob_proto + i) = t[3]; GET_RACE(mob_proto + i) = t[4];

Each of the %d's is a number that sscanf looks for, and puts the value into the t[] character. Make sure t[] has at least 5 when you declare it. I think stock has plenty.

t[4] = 0; means the default race for existing mobs will be race #0, change that to what you need.

Once you boot the MUD up go through and save all the mob files and they should write the new race values to file, then you can comment in the exit(1); part to catch errors in formatting again.

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

More
01 Sep 2014 20:53 #5024 by Liko
Replied by Liko on topic Mobile Race Snippet

WhiskyTest wrote: It depends how the new code is writing the extra race information, but assuming it is adding on one additional value to this line you would write something like:

Code:
if (sscanf(line, " %d %d %d %d %d ", t, t + 1, t + 2, t + 3, t + 4) != 5) { log("SYSERR: Format error in last line of mob #%d, converting..\n" "...expecting line of form '# # # # #'", nr); //exit(1); comment this out until you have saved all the mobs with the new format t[4] = 0; // arbitrarily set a default race if none was scanned above } GET_POS(mob_proto + i) = t[0]; GET_DEFAULT_POS(mob_proto + i) = t[1]; GET_SEX(mob_proto + i) = t[2]; GET_CLASS(mob_proto + i) = t[3]; GET_RACE(mob_proto + i) = t[4];

Each of the %d's is a number that sscanf looks for, and puts the value into the t[] character. Make sure t[] has at least 5 when you declare it. I think stock has plenty.

t[4] = 0; means the default race for existing mobs will be race #0, change that to what you need.

Once you boot the MUD up go through and save all the mob files and they should write the new race values to file, then you can comment in the exit(1); part to catch errors in formatting again.


I may have got it fixed. Going to run a test on a clean TbaMUD and see what happens.

Randian(0.0.0)
Owner/Developer

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

Time to create page: 0.183 seconds