ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/loader.l
(Generate patch)

Comparing deliantra/server/common/loader.l (file contents):
Revision 1.1 by root, Fri Feb 3 07:11:36 2006 UTC vs.
Revision 1.7 by elmex, Sun Aug 13 17:16:00 2006 UTC

1%{ 1%{
2/* 2/*
3 * static char *rcsid_object_c = 3 * static char *rcsid_object_c =
4 * "$Id: loader.l,v 1.1 2006/02/03 07:11:36 root Exp $"; 4 * "$Id: loader.l,v 1.7 2006/08/13 17:16:00 elmex Exp $";
5 */ 5 */
6 6
7/* 7/*
8 CrossFire, A Multiplayer game for X-windows 8 CrossFire, A Multiplayer game for X-windows
9 9
42static char *yval(); 42static char *yval();
43 43
44static int lex_error; 44static int lex_error;
45static char msgbuf[HUGE_BUF]; 45static char msgbuf[HUGE_BUF];
46static char lorebuf[HUGE_BUF]; 46static char lorebuf[HUGE_BUF];
47
48/* Maps the MOVE_* values to names */
49static const char *const move_name[] = {"walk", "fly_low", "fly_high", "swim", "boat",
50 NULL};
47 51
48/* This table is only necessary to convert objects that existed before the 52/* This table is only necessary to convert objects that existed before the
49 * spell object conversion to the new object. It was not practical 53 * spell object conversion to the new object. It was not practical
50 * to go through every mapping looking for every potion, rod, wand, etc 54 * to go through every mapping looking for every potion, rod, wand, etc
51 * that had a sp set and update to the new value. So this maps the 55 * that had a sp set and update to the new value. So this maps the
53 * If you are adding a new spell, you should not modify this - you 57 * If you are adding a new spell, you should not modify this - you
54 * new spell won't have been used, and thus won't have any legacy object. 58 * new spell won't have been used, and thus won't have any legacy object.
55 * NULL entries in this table are valid - to denote objects that should 59 * NULL entries in this table are valid - to denote objects that should
56 * not be updated for whatever reason. 60 * not be updated for whatever reason.
57 */ 61 */
58char *spell_mapping[] = { 62const char *spell_mapping[] = {
59"spell_magic_bullet", /* 0 */ 63"spell_magic_bullet", /* 0 */
60"spell_small_fireball", /* 1 */ 64"spell_small_fireball", /* 1 */
61"spell_medium_fireball", /* 2 */ 65"spell_medium_fireball", /* 2 */
62"spell_large_fireball", /* 3 */ 66"spell_large_fireball", /* 3 */
63"spell_burning_hands", /* 4 */ 67"spell_burning_hands", /* 4 */
321 } 325 }
322 } 326 }
323 LOG(llevError,"set_body_info called with bogus params: %s\n", params); 327 LOG(llevError,"set_body_info called with bogus params: %s\n", params);
324} 328}
325 329
330// return a suitable strign describign an objetc in enough detail to find it
331// used only in check_loaded_object: TODO remove static, move it elsewhere and
332// use it in more log messages.
333static char *op_debug_info_ (object *op, char *info)
334{
335 char info2[256 * 3];
336 char *p = info;
337
338 p += snprintf (p, 256, "%d=\"%s%s%s\"",
339 op->count,
340 op->name ? op->name : "(anon)",
341 op->title ? " " : "",
342 op->title ? op->title : "");
343
344 if (op->env)
345 p += snprintf (p, 256, "(in %s)", op_debug_info_ (op->env, info2));
346
347 if (op->map)
348 p += snprintf (p, 256, "(on %s@%d+%d)", op->map->path, op->x, op->y);
349
350 return info;
351}
352
353static char *op_debug_info (object *op)
354{
355 static char info[256 * 3];
356
357 return op_debug_info_ (op, info);
358}
326 359
327/* This function checks the object after it has been loaded (when we 360/* This function checks the object after it has been loaded (when we
328 * get the 'end' in the input stream). This function can be used to 361 * get the 'end' in the input stream). This function can be used to
329 * deal with legacy objects where fields may have changed. It can also be used 362 * deal with legacy objects where fields may have changed. It can also be used
330 * to check for objects to make sure there are no common errors. 363 * to check for objects to make sure there are no common errors.
359 * really just to catch any errors - program will still run, but 392 * really just to catch any errors - program will still run, but
360 * not in the ideal fashion. 393 * not in the ideal fashion.
361 */ 394 */
362 if ((op->type == WEAPON || op->type==BOW) && arch_init) { 395 if ((op->type == WEAPON || op->type==BOW) && arch_init) {
363 if (!op->skill) { 396 if (!op->skill) {
364 LOG(llevError,"Weapon %s lacks a skill.\n", op->name); 397 LOG(llevError,"Weapon %s lacks a skill.\n", op_debug_info (op));
365 } else if ((!strcmp(op->skill,"one handed weapons") && op->body_info[1] != -1) || 398 } else if ((!strcmp(op->skill,"one handed weapons") && op->body_info[1] != -1) ||
366 (!strcmp(op->skill,"two handed weapons") && op->body_info[1] != -2)) { 399 (!strcmp(op->skill,"two handed weapons") && op->body_info[1] != -2)) {
367 LOG(llevError,"weapon %s arm usage does not match skill: %d, %s\n", 400 LOG(llevError,"weapon %s arm usage does not match skill: %d, %s\n",
368 op->name, op->body_info[1], op->skill); 401 op_debug_info (op), op->body_info[1], op->skill);
369 } 402 }
370 } 403 }
371 404
372 /* We changed last_heal to gen_sp_armour, which is what it 405 /* We changed last_heal to gen_sp_armour, which is what it
373 * really does for many objects. Need to catch any in maps 406 * really does for many objects. Need to catch any in maps
378 (op->type == SHIELD) || (op->type == RING) || 411 (op->type == SHIELD) || (op->type == RING) ||
379 (op->type == BOOTS) || (op->type == GLOVES) || 412 (op->type == BOOTS) || (op->type == GLOVES) ||
380 (op->type == AMULET ) || (op->type == GIRDLE) || 413 (op->type == AMULET ) || (op->type == GIRDLE) ||
381 (op->type == BRACERS ) || (op->type == CLOAK)) { 414 (op->type == BRACERS ) || (op->type == CLOAK)) {
382 if (op->last_heal) { 415 if (op->last_heal) {
383 LOG(llevDebug,"Object %s still has last_heal set, not gen_sp_armour\n", 416 LOG(llevDebug,"Object %s still has last_heal set, not gen_sp_armour\n", op_debug_info (op));
384 op->name?op->name:"NULL");
385 op->gen_sp_armour = op->last_heal; 417 op->gen_sp_armour = op->last_heal;
386 op->last_heal = 0; 418 op->last_heal = 0;
387 } 419 }
388 if (editor) ip =0; 420 if (editor) ip =0;
389 else ip = calc_item_power(op, 0); 421 else ip = calc_item_power(op, 0);
390 /* Legacy objects from before item power was in the game */ 422 /* Legacy objects from before item power was in the game */
391 if (!op->item_power && ip) { 423 if (!op->item_power && ip) {
392 if (ip > 3) { 424 if (ip > 3) {
393 LOG(llevDebug,"Object %s had no item power, using %d\n", 425 LOG(llevDebug,"Object %s had no item power, using %d\n", op_debug_info (op), ip);
394 op->name?op->name:"NULL", ip);
395 } 426 }
396 op->item_power = ip; 427 op->item_power = ip;
397 } 428 }
398 /* Check for possibly bogus values. Has to meet both these criteria - 429 /* Check for possibly bogus values. Has to meet both these criteria -
399 * something that has item_power 1 is probably just fine if our calculated 430 * something that has item_power 1 is probably just fine if our calculated
401 * similarly, it item_power is 0, the first check will always pass, 432 * similarly, it item_power is 0, the first check will always pass,
402 * but not the second one. 433 * but not the second one.
403 */ 434 */
404 if (ip > 2 *op->item_power && ip > (op->item_power + 3)) { 435 if (ip > 2 *op->item_power && ip > (op->item_power + 3)) {
405 LOG(llevDebug,"Object %s seems to have too low item power? %d > %d\n", 436 LOG(llevDebug,"Object %s seems to have too low item power? %d > %d\n",
406 op->name?op->name:"NULL", ip, op->item_power); 437 op_debug_info (op), ip, op->item_power);
407 } 438 }
408 439
409 } 440 }
410 /* Old spellcasting object - need to load in the appropiate object */ 441 /* Old spellcasting object - need to load in the appropiate object */
411 if ((op->type == ROD || op->type == WAND || op->type == SCROLL || op->type == HORN 442 if ((op->type == ROD || op->type == WAND || op->type == SCROLL || op->type == HORN
434 } 465 }
435 466
436 if (QUERY_FLAG(op, FLAG_MONSTER)) { 467 if (QUERY_FLAG(op, FLAG_MONSTER)) {
437 if (op->stats.hp > op->stats.maxhp) 468 if (op->stats.hp > op->stats.maxhp)
438 LOG(llevDebug,"Monster %s has hp set higher than maxhp (%d>%d)\n", 469 LOG(llevDebug,"Monster %s has hp set higher than maxhp (%d>%d)\n",
439 op->name, 470 op_debug_info (op),
440 op->stats.hp, op->stats.maxhp); 471 op->stats.hp, op->stats.maxhp);
441 472
442 /* The archs just need to be updated for this */ 473 /* The archs just need to be updated for this */
443 if (op->move_type ==0) op->move_type = MOVE_WALK; 474 if (op->move_type ==0) op->move_type = MOVE_WALK;
444 } 475 }
535 *end='\0'; 566 *end='\0';
536 } 567 }
537 set_ob_key_value(op, key, value, TRUE); 568 set_ob_key_value(op, key, value, TRUE);
538} 569}
539 570
571static void set_move(MoveType *mt, char *params) {
572 char *str;
573 int i, negate;
574
575 if (isdigit(*params)) {
576 *mt = atoi(params);
577 } else {
578 *mt=0;
579 for (str=strtok(params, " "); str; str=strtok(NULL, " ")) {
580 negate=0;
581 if (!strcasecmp(str, "all"))
582 *mt |= MOVE_ALL;
583 else {
584 if (*str=='-') {
585 negate = 1;
586 str++;
587 }
588 for (i=0; move_name[i] != NULL; i++) {
589 if (!strcasecmp(move_name[i], str)) {
590 if (negate) {
591 *mt &= ~(1<<i);
592 } else {
593 *mt |= (1<<i);
594 }
595 break;
596 }
597 }
598 if (move_name[i] == NULL) {
599 /* fly is a special case - covers both fly_low and
600 * fly_high - since it doesn't match to a specific
601 * single bit, have to special case it.
602 */
603 if (!strcasecmp(str,"flying")) {
604 if (negate) {
605 *mt &= ~MOVE_FLYING;
606 } else {
607 *mt |= MOVE_FLYING;
608 }
609 } else {
610 LOG(llevDebug, "common/loader.l: set_move - unknown move string '%s'\n", str);
611 }
612 }
613 } /* Else not all move types */
614 } /* for strtok */
615 } /* Else not a numeric value */
616}
540 617
541%} 618%}
542 619
543 620
544 621
566 643
567%} 644%}
568 645
569^msg{WS}$ { BEGIN( MESSAGE ); msgbuf[0]='\0'; } 646^msg{WS}$ { BEGIN( MESSAGE ); msgbuf[0]='\0'; }
570<MESSAGE>^endmsg{WS}$ { BEGIN( INITIAL ); 647<MESSAGE>^endmsg{WS}$ { BEGIN( INITIAL );
571 op->msg=add_string(msgbuf);
572 /* Just print a warning so we can be reasonably safe 648 /* Just print a warning so we can be reasonably safe
573 * about not overflowing the buffer. 649 * about not overflowing the buffer.
574 */ 650 */
575 if (strlen(op->msg) > (HUGE_BUF/2)) 651 if (strlen(msgbuf) >= HUGE_BUF)
652 {
576 LOG(llevDebug, "\n\tWarning message length > %d (max allowed=%d): %d\n>%.80s<\n", 653 LOG(llevDebug, "\n\tError message length >= %d: %d\n>%.80s<\n",
577 HUGE_BUF/2, HUGE_BUF, strlen(op->msg),op->msg); 654 HUGE_BUF, strlen(op->msg),op->msg);
655 op->msg = add_string ("ERROR, please report: string too long, winged.\n");
656 }
657 else
658 op->msg = add_string (msgbuf);
578 } 659 }
579<MESSAGE>.* {strcat(msgbuf, yytext); strcat(msgbuf,"\n"); } 660<MESSAGE>.* {strcat(msgbuf, yytext); strcat(msgbuf,"\n"); }
580 661
581^lore{WS}$ { BEGIN( LORE ); lorebuf[0]='\0'; } 662^lore{WS}$ { BEGIN( LORE ); lorebuf[0]='\0'; }
582<LORE>^endlore{WS}$ { BEGIN( INITIAL ); 663<LORE>^endlore{WS}$ { BEGIN( INITIAL );
769^fly_off{S} { if (IVAL) op->move_off |= MOVE_FLY_LOW; else op->move_off &= ~MOVE_FLY_LOW; } 850^fly_off{S} { if (IVAL) op->move_off |= MOVE_FLY_LOW; else op->move_off &= ~MOVE_FLY_LOW; }
770^flying{S} { if (IVAL) op->move_type |= MOVE_FLY_LOW; else op->move_type &= ~MOVE_FLY_LOW; } 851^flying{S} { if (IVAL) op->move_type |= MOVE_FLY_LOW; else op->move_type &= ~MOVE_FLY_LOW; }
771 852
772%{ /* These are the new values */ 853%{ /* These are the new values */
773%} 854%}
774^move_block{S} op->move_block = IVAL; 855^move_block{S} set_move(&op->move_block, yval());
775^move_type{S} op->move_type = IVAL; 856^move_allow{S} set_move(&op->move_allow, yval());
776^move_on{S} op->move_on = IVAL; 857^move_type{S} set_move(&op->move_type, yval());
777^move_off{S} op->move_off = IVAL; 858^move_on{S} set_move(&op->move_on, yval());
778^move_slow{S} op->move_slow = IVAL; 859^move_off{S} set_move(&op->move_off, yval());
860^move_slow{S} set_move(&op->move_slow, yval());
779^move_slow_penalty{S} op->move_slow_penalty = FVAL; 861^move_slow_penalty{S} op->move_slow_penalty = FVAL;
780 862
781 863
782^monster{S} SET_OR_CLEAR_FLAG(op, FLAG_MONSTER, IVAL); 864^monster{S} SET_OR_CLEAR_FLAG(op, FLAG_MONSTER, IVAL);
783^neutral{S} SET_OR_CLEAR_FLAG(op, FLAG_NEUTRAL, IVAL); 865^neutral{S} SET_OR_CLEAR_FLAG(op, FLAG_NEUTRAL, IVAL);
784^no_attack{S} SET_OR_CLEAR_FLAG(op, FLAG_NO_ATTACK, IVAL); 866^no_attack{S} SET_OR_CLEAR_FLAG(op, FLAG_NO_ATTACK, IVAL);
785^no_damage{S} SET_OR_CLEAR_FLAG(op, FLAG_NO_DAMAGE, IVAL); 867^no_damage{S} SET_OR_CLEAR_FLAG(op, FLAG_NO_DAMAGE, IVAL);
786^friendly{S} { if (IVAL) { 868^friendly{S} { if (IVAL) {
787 SET_FLAG(op, FLAG_FRIENDLY); 869 SET_FLAG(op, FLAG_FRIENDLY);
788 if (op->type != PLAYER) { 870 if (op->type != PLAYER)
789 LOG(llevDebug," Adding friendly object %s.\n",op->name);
790 add_friendly_object(op); 871 add_friendly_object (op);
791 }
792 } 872 }
793 else CLEAR_FLAG(op, FLAG_FRIENDLY); 873 else CLEAR_FLAG(op, FLAG_FRIENDLY);
794 } 874 }
795^generator{S} SET_OR_CLEAR_FLAG(op, FLAG_GENERATOR, IVAL); 875^generator{S} SET_OR_CLEAR_FLAG(op, FLAG_GENERATOR, IVAL);
796^use_content_on_gen{S} SET_OR_CLEAR_FLAG (op,FLAG_CONTENT_ON_GEN, IVAL); 876^use_content_on_gen{S} SET_OR_CLEAR_FLAG (op,FLAG_CONTENT_ON_GEN, IVAL);
904^resist_disease{S} SET_RESIST(op, ATNR_DISEASE, IVAL); 984^resist_disease{S} SET_RESIST(op, ATNR_DISEASE, IVAL);
905 985
906 /* Old style resistances */ 986 /* Old style resistances */
907^immune{S} set_protection(op, IVAL, RESIST_IMMUNE); 987^immune{S} set_protection(op, IVAL, RESIST_IMMUNE);
908^protected{S} set_protection(op, IVAL, RESIST_PROT); 988^protected{S} set_protection(op, IVAL, RESIST_PROT);
909^vulnerable{S} set_protection(op, IVAL, RESIST_VULN); 989^vulnerable{S} set_protection(op, IVAL, (uint16) RESIST_VULN);
910 990
911 /* old values - keep them around for now, but they should be removed at some point */ 991 /* old values - keep them around for now, but they should be removed at some point */
912^has_ready_rod{S} SET_OR_CLEAR_FLAG(op, FLAG_READY_RANGE, IVAL); 992^has_ready_rod{S} SET_OR_CLEAR_FLAG(op, FLAG_READY_RANGE, IVAL);
913^has_ready_horn{S} SET_OR_CLEAR_FLAG(op, FLAG_READY_RANGE, IVAL); 993^has_ready_horn{S} SET_OR_CLEAR_FLAG(op, FLAG_READY_RANGE, IVAL);
914^has_ready_wand{S} SET_OR_CLEAR_FLAG(op, FLAG_READY_RANGE, IVAL); 994^has_ready_wand{S} SET_OR_CLEAR_FLAG(op, FLAG_READY_RANGE, IVAL);
953^can_impale{S} { /* That these are for the new combat code */ } 1033^can_impale{S} { /* That these are for the new combat code */ }
954^can_cut{S} { /* just ignore for now */ } 1034^can_cut{S} { /* just ignore for now */ }
955^can_dam_armour{S} { } 1035^can_dam_armour{S} { }
956^weapontype{S} op->weapontype = IVAL; 1036^weapontype{S} op->weapontype = IVAL;
957^tooltype{S} op->tooltype = IVAL; 1037^tooltype{S} op->tooltype = IVAL;
958^casting_time{S} op->casting_time = FVAL; 1038^casting_time{S} op->casting_time = (sint16) FVAL;
959^elevation{S} op->elevation = IVAL; 1039^elevation{S} op->elevation = IVAL;
960^smoothlevel{S} op->smoothlevel = IVAL; 1040^smoothlevel{S} op->smoothlevel = IVAL;
961^client_type{S} op->client_type = IVAL; 1041^client_type{S} op->client_type = IVAL;
962^body_{A} set_body_info(op, yytext); 1042^body_{A} set_body_info(op, yytext);
963^duration{S} op->duration = IVAL; 1043^duration{S} op->duration = IVAL;
1386/* This is a list of pointers that correspond to the FLAG_.. values. 1466/* This is a list of pointers that correspond to the FLAG_.. values.
1387 * This is a simple 1:1 mapping - if FLAG_FRIENDLY is 15, then 1467 * This is a simple 1:1 mapping - if FLAG_FRIENDLY is 15, then
1388 * the 15'th element of this array should match that name. 1468 * the 15'th element of this array should match that name.
1389 * If an entry is NULL, that is a flag not to loaded/saved. 1469 * If an entry is NULL, that is a flag not to loaded/saved.
1390 */ 1470 */
1391static char *flag_names[NUM_FLAGS+1] = { 1471static const char *const flag_names[NUM_FLAGS+1] = {
1392"alive", "wiz", NULL, NULL, "was_wiz", "applied", "unpaid", 1472"alive", "wiz", NULL, NULL, "was_wiz", "applied", "unpaid",
1393"can_use_shield", "no_pick", NULL /* walk_on*/, NULL /* no_pass */, /* 10 */ 1473"can_use_shield", "no_pick", NULL /* walk_on*/, NULL /* no_pass */, /* 10 */
1394"is_animated", NULL /* slow_move */, 1474"is_animated", NULL /* slow_move */,
1395NULL /* flying */, "monster", "friendly", "generator", 1475NULL /* flying */, "monster", "friendly", "generator",
1396"is_thrown", "auto_apply", "treasure", "player sold", /* 20 */ 1476"is_thrown", "auto_apply", "treasure", "player sold", /* 20 */
1420"activate_on_release", "is_water", "use_content_on_gen", NULL, "is_buildable", /* 110 */ 1500"activate_on_release", "is_water", "use_content_on_gen", NULL, "is_buildable", /* 110 */
1421NULL 1501NULL
1422}; 1502};
1423 1503
1424 1504
1425void save_double(char *buf,char *name,double v)
1426{
1427 char tbuf[200];
1428
1429 sprintf(tbuf,"%s %f\n",name,v);
1430 strcat(buf,tbuf);
1431}
1432
1433/* 1505/*
1434 * Initialises the array of variable-names. Needed before any 1506 * Initialises the array of variable-names. Needed before any
1435 * objects can be loaded. Called by init_library(). 1507 * objects can be loaded. Called by init_library().
1436 */ 1508 */
1437 1509
1438void init_vars() { 1510void init_vars() {
1439} 1511}
1440 1512
1441/*For get_ob_diff speed reason*/ 1513/*For get_ob_diff speed reason*/
1442typedef struct { 1514typedef struct {
1443 char* name; 1515 const char *name;
1444 int length; 1516 int length;
1445}genericname; 1517}genericname;
1446static genericname evtnames[13]= 1518static genericname evtnames[13]=
1447{ 1519{
1448 {"event_none ",11}, 1520 {"event_none ",11},
1492 {"event_trigger_options ",22}, 1564 {"event_trigger_options ",22},
1493 {"event_close_options ",20}, 1565 {"event_close_options ",20},
1494 {"event_timer_options ",20} 1566 {"event_timer_options ",20}
1495}; 1567};
1496 1568
1569/* This returns a string of the integer movement type */
1570static char* get_string_move_type(MoveType mt)
1571{
1572 static char retbuf[MAX_BUF], retbuf_all[MAX_BUF];
1573 int i, all_count=0, count;
1574
1575 strcpy(retbuf,"");
1576 strcpy(retbuf_all," all");
1577
1578 /* Quick check, and probably fairly common */
1579 if (mt == MOVE_ALL) return retbuf_all+1;
1580 if (mt == 0) {
1581 strcpy(retbuf,"0");
1582 return retbuf;
1583 }
1584
1585 /* We basically slide the bits down. Why look at MOVE_ALL?
1586 * because we may want to return a string like 'all -swim',
1587 * and if we just looked at mt, we couldn't get that.
1588 */
1589 for (i=MOVE_ALL, count=0; i!=0; i >>= 1, count++) {
1590 if (mt & (1<<count)) {
1591 strcat(retbuf, " ");
1592 strcat(retbuf, move_name[count]);
1593 } else {
1594 strcat(retbuf_all, " -");
1595 strcat(retbuf_all, move_name[count]);
1596 all_count++;
1597 }
1598 }
1599 /* Basically, if there is a single negation, return it, eg
1600 * 'all -swim'. But more than that, just return the
1601 * enumerated values. It doesn't make sense to return
1602 * 'all -walk -fly_low' - it is shorter to return 'fly_high swim'
1603 */
1604 if (all_count <=1) return retbuf_all+1;
1605 else return retbuf+1;
1606}
1607
1608
1497/* 1609/*
1498 * Returns a pointer to a static string which contains all variables 1610 * Returns a pointer to a static string which contains all variables
1499 * which are different in the two given objects. op is the what object 1611 * which are different in the two given objects. op is the what object
1500 * the different values will be taken from. This function is 1612 * the different values will be taken from. This function is
1501 * typically used to dump objects (op2=empty object), or to save objects 1613 * typically used to dump objects (op2=empty object), or to save objects
1535 * NEVER touch buf between PREPARE_FASTCAT(buf) and 1647 * NEVER touch buf between PREPARE_FASTCAT(buf) and
1536 * FINISH_FASTCAT(buf) 1648 * FINISH_FASTCAT(buf)
1537 */ 1649 */
1538 static int already_run = 0; 1650 static int already_run = 0;
1539 static int flag_lens[NUM_FLAGS]; 1651 static int flag_lens[NUM_FLAGS];
1540 static char buf2[HUGE_BUF]; 1652 char buf2[4096]; // / was HUFE_BUF, which was hugely incorrect, as is this value, but much less so
1541 static char buf[HUGE_BUF]; 1653 static char buf[128*1024]; // < the assumption is that every object always fits. fixing this bug, however
1542 char* fastbuf; 1654 char* fastbuf; // \ requires a large rewrite of the code, so its left to the next total rewrite.
1543 int tmp; 1655 int tmp;
1544 int i; 1656 int i;
1545#if 0
1546/*Memory polluting code. Should help detect problems, very slow*/
1547 for (i=0;i<HUGE_BUF;i++){
1548 buf[i]='a'+(unsigned short)(i%25);
1549 }
1550#endif
1551 event *etmp; 1657 event *etmp;
1552 event *etmp2; 1658 event *etmp2;
1553 key_value * my_field; 1659 key_value * my_field;
1554 key_value * arch_field; 1660 key_value * arch_field;
1555 1661
1684 if(op->stats.maxgrace!=op2->stats.maxgrace) 1790 if(op->stats.maxgrace!=op2->stats.maxgrace)
1685 FAST_SAVE_LONG(fastbuf,"maxgrace ",op->stats.maxgrace,9); 1791 FAST_SAVE_LONG(fastbuf,"maxgrace ",op->stats.maxgrace,9);
1686 1792
1687 if(op->stats.exp!=op2->stats.exp) { 1793 if(op->stats.exp!=op2->stats.exp) {
1688#ifndef WIN32 1794#ifndef WIN32
1689 sprintf(buf2,"%lld\n", op->stats.exp); 1795 sprintf(buf2,"%lld", op->stats.exp);
1690#else 1796#else
1691 sprintf(buf2,"%I64d\n", op->stats.exp); 1797 sprintf(buf2,"%I64d", op->stats.exp);
1692#endif 1798#endif
1693 ADD_STRINGLINE_ENTRY(fastbuf,"exp ", buf2, 4); 1799 ADD_STRINGLINE_ENTRY(fastbuf,"exp ", buf2, 4);
1694 } 1800 }
1695 1801
1696 if(op->perm_exp!=op2->perm_exp) { 1802 if(op->perm_exp!=op2->perm_exp) {
1697#ifndef WIN32 1803#ifndef WIN32
1698 sprintf(buf2,"%lld\n", op->perm_exp); 1804 sprintf(buf2,"%lld", op->perm_exp);
1699#else 1805#else
1700 sprintf(buf2,"%I64d\n", op->perm_exp); 1806 sprintf(buf2,"%I64d", op->perm_exp);
1701#endif 1807#endif
1702 ADD_STRINGLINE_ENTRY(fastbuf,"perm_exp ", buf2, 9); 1808 ADD_STRINGLINE_ENTRY(fastbuf,"perm_exp ", buf2, 9);
1703 } 1809 }
1704 1810
1705 if(op->expmul!=op2->expmul) 1811 if(op->expmul!=op2->expmul)
1843 1949
1844 if (op->gen_sp_armour != op2->gen_sp_armour) { 1950 if (op->gen_sp_armour != op2->gen_sp_armour) {
1845 FAST_SAVE_LONG(fastbuf,"gen_sp_armour ",op->gen_sp_armour,14); 1951 FAST_SAVE_LONG(fastbuf,"gen_sp_armour ",op->gen_sp_armour,14);
1846 } 1952 }
1847 1953
1954 /* I've kept the old int move type saving code commented out.
1955 * In an ideal world, we'd know if we want to do a quick
1956 * save (say to a temp map, where we don't care about strings),
1957 * or a slower save/dm dump, where printing out strings is handy.
1958 */
1848 if (op->move_type != op2->move_type) { 1959 if (op->move_type != op2->move_type) {
1849 FAST_SAVE_LONG(fastbuf,"move_type ",op->move_type,10); 1960 /*FAST_SAVE_LONG(fastbuf,"move_type ",op->move_type,10)*/
1961 ADD_STRINGLINE_ENTRY(fastbuf,"move_type ",
1962 get_string_move_type(op->move_type),
1963 10);
1850 } 1964 }
1851
1852 if (op->move_block != op2->move_block) { 1965 if (op->move_block != op2->move_block) {
1853 FAST_SAVE_LONG(fastbuf,"move_block ",op->move_block,11); 1966 /*FAST_SAVE_LONG(fastbuf,"move_block ",op->move_block,11)*/
1967 ADD_STRINGLINE_ENTRY(fastbuf,"move_block ",
1968 get_string_move_type(op->move_block),
1969 11);
1854 } 1970 }
1855 1971 if (op->move_allow != op2->move_allow) {
1972 /*FAST_SAVE_LONG(fastbuf,"move_allow ",op->move_allow,11);*/
1973 ADD_STRINGLINE_ENTRY(fastbuf,"move_allow ",
1974 get_string_move_type(op->move_allow),
1975 11);
1976 }
1856 if (op->move_on != op2->move_on) { 1977 if (op->move_on != op2->move_on) {
1857 FAST_SAVE_LONG(fastbuf,"move_on ",op->move_on,8); 1978 /*FAST_SAVE_LONG(fastbuf,"move_on ",op->move_on,8);*/
1979 ADD_STRINGLINE_ENTRY(fastbuf,"move_on ",
1980 get_string_move_type(op->move_on),
1981 8);
1858 } 1982 }
1859
1860 if (op->move_off != op2->move_off) { 1983 if (op->move_off != op2->move_off) {
1861 FAST_SAVE_LONG(fastbuf,"move_off ",op->move_off,9); 1984 /*FAST_SAVE_LONG(fastbuf,"move_off ",op->move_off,9);*/
1985 ADD_STRINGLINE_ENTRY(fastbuf,"move_off ",
1986 get_string_move_type(op->move_off),
1987 9);
1862 } 1988 }
1863 if (op->move_slow != op2->move_slow) { 1989 if (op->move_slow != op2->move_slow) {
1864 FAST_SAVE_LONG(fastbuf,"move_slow ",op->move_slow,10); 1990 /*FAST_SAVE_LONG(fastbuf,"move_slow ",op->move_slow,10);*/
1991 ADD_STRINGLINE_ENTRY(fastbuf,"move_slow ",
1992 get_string_move_type(op->move_slow),
1993 10);
1865 } 1994 }
1866 1995
1867 if (op->move_slow_penalty != op2->move_slow_penalty) { 1996 if (op->move_slow_penalty != op2->move_slow_penalty) {
1868 FAST_SAVE_LONG(fastbuf,"move_slow_penalty ",op->move_slow_penalty,18); 1997 FAST_SAVE_LONG(fastbuf,"move_slow_penalty ",(long) op->move_slow_penalty,18);
1869 } 1998 }
1870 1999
1871 if (!COMPARE_FLAGS(op,op2)) { 2000 if (!COMPARE_FLAGS(op,op2)) {
1872 for (tmp=0; tmp <= NUM_FLAGS; tmp++) { 2001 for (tmp=0; tmp <= NUM_FLAGS; tmp++) {
1873 if (flag_names[tmp] && (QUERY_FLAG(op, tmp) != QUERY_FLAG(op2, tmp))) { 2002 if (flag_names[tmp] && (QUERY_FLAG(op, tmp) != QUERY_FLAG(op2, tmp))) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines