1 | %{ |
1 | %{ |
2 | /* |
2 | /* |
3 | * static char *rcsid_object_c = |
3 | * static char *rcsid_object_c = |
4 | * "$Id: loader.l,v 1.1.1.2 2006/02/22 18:01:20 elmex Exp $"; |
4 | * "$Id: loader.l,v 1.5 2006/06/26 21:46:04 root 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 | |
… | |
… | |
325 | } |
325 | } |
326 | } |
326 | } |
327 | 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); |
328 | } |
328 | } |
329 | |
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. |
|
|
333 | static 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 | |
|
|
353 | static char *op_debug_info (object *op) |
|
|
354 | { |
|
|
355 | static char info[256 * 3]; |
|
|
356 | |
|
|
357 | return op_debug_info_ (op, info); |
|
|
358 | } |
330 | |
359 | |
331 | /* 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 |
332 | * 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 |
333 | * 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 |
334 | * 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. |
… | |
… | |
363 | * really just to catch any errors - program will still run, but |
392 | * really just to catch any errors - program will still run, but |
364 | * not in the ideal fashion. |
393 | * not in the ideal fashion. |
365 | */ |
394 | */ |
366 | if ((op->type == WEAPON || op->type==BOW) && arch_init) { |
395 | if ((op->type == WEAPON || op->type==BOW) && arch_init) { |
367 | if (!op->skill) { |
396 | if (!op->skill) { |
368 | LOG(llevError,"Weapon %s lacks a skill.\n", op->name); |
397 | LOG(llevError,"Weapon %s lacks a skill.\n", op_debug_info (op)); |
369 | } 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) || |
370 | (!strcmp(op->skill,"two handed weapons") && op->body_info[1] != -2)) { |
399 | (!strcmp(op->skill,"two handed weapons") && op->body_info[1] != -2)) { |
371 | 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", |
372 | op->name, op->body_info[1], op->skill); |
401 | op_debug_info (op), op->body_info[1], op->skill); |
373 | } |
402 | } |
374 | } |
403 | } |
375 | |
404 | |
376 | /* 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 |
377 | * really does for many objects. Need to catch any in maps |
406 | * really does for many objects. Need to catch any in maps |
… | |
… | |
382 | (op->type == SHIELD) || (op->type == RING) || |
411 | (op->type == SHIELD) || (op->type == RING) || |
383 | (op->type == BOOTS) || (op->type == GLOVES) || |
412 | (op->type == BOOTS) || (op->type == GLOVES) || |
384 | (op->type == AMULET ) || (op->type == GIRDLE) || |
413 | (op->type == AMULET ) || (op->type == GIRDLE) || |
385 | (op->type == BRACERS ) || (op->type == CLOAK)) { |
414 | (op->type == BRACERS ) || (op->type == CLOAK)) { |
386 | if (op->last_heal) { |
415 | if (op->last_heal) { |
387 | 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)); |
388 | op->name?op->name:"NULL"); |
|
|
389 | op->gen_sp_armour = op->last_heal; |
417 | op->gen_sp_armour = op->last_heal; |
390 | op->last_heal = 0; |
418 | op->last_heal = 0; |
391 | } |
419 | } |
392 | if (editor) ip =0; |
420 | if (editor) ip =0; |
393 | else ip = calc_item_power(op, 0); |
421 | else ip = calc_item_power(op, 0); |
394 | /* Legacy objects from before item power was in the game */ |
422 | /* Legacy objects from before item power was in the game */ |
395 | if (!op->item_power && ip) { |
423 | if (!op->item_power && ip) { |
396 | if (ip > 3) { |
424 | if (ip > 3) { |
397 | 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); |
398 | op->name?op->name:"NULL", ip); |
|
|
399 | } |
426 | } |
400 | op->item_power = ip; |
427 | op->item_power = ip; |
401 | } |
428 | } |
402 | /* Check for possibly bogus values. Has to meet both these criteria - |
429 | /* Check for possibly bogus values. Has to meet both these criteria - |
403 | * 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 |
… | |
… | |
405 | * 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, |
406 | * but not the second one. |
433 | * but not the second one. |
407 | */ |
434 | */ |
408 | if (ip > 2 *op->item_power && ip > (op->item_power + 3)) { |
435 | if (ip > 2 *op->item_power && ip > (op->item_power + 3)) { |
409 | 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", |
410 | op->name?op->name:"NULL", ip, op->item_power); |
437 | op_debug_info (op), ip, op->item_power); |
411 | } |
438 | } |
412 | |
439 | |
413 | } |
440 | } |
414 | /* Old spellcasting object - need to load in the appropiate object */ |
441 | /* Old spellcasting object - need to load in the appropiate object */ |
415 | 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 |
… | |
… | |
438 | } |
465 | } |
439 | |
466 | |
440 | if (QUERY_FLAG(op, FLAG_MONSTER)) { |
467 | if (QUERY_FLAG(op, FLAG_MONSTER)) { |
441 | if (op->stats.hp > op->stats.maxhp) |
468 | if (op->stats.hp > op->stats.maxhp) |
442 | 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", |
443 | op->name, |
470 | op_debug_info (op), |
444 | op->stats.hp, op->stats.maxhp); |
471 | op->stats.hp, op->stats.maxhp); |
445 | |
472 | |
446 | /* The archs just need to be updated for this */ |
473 | /* The archs just need to be updated for this */ |
447 | if (op->move_type ==0) op->move_type = MOVE_WALK; |
474 | if (op->move_type ==0) op->move_type = MOVE_WALK; |
448 | } |
475 | } |
… | |
… | |
616 | |
643 | |
617 | %} |
644 | %} |
618 | |
645 | |
619 | ^msg{WS}$ { BEGIN( MESSAGE ); msgbuf[0]='\0'; } |
646 | ^msg{WS}$ { BEGIN( MESSAGE ); msgbuf[0]='\0'; } |
620 | <MESSAGE>^endmsg{WS}$ { BEGIN( INITIAL ); |
647 | <MESSAGE>^endmsg{WS}$ { BEGIN( INITIAL ); |
621 | op->msg=add_string(msgbuf); |
|
|
622 | /* Just print a warning so we can be reasonably safe |
648 | /* Just print a warning so we can be reasonably safe |
623 | * about not overflowing the buffer. |
649 | * about not overflowing the buffer. |
624 | */ |
650 | */ |
625 | if (strlen(op->msg) > (HUGE_BUF/2)) |
651 | if (strlen(msgbuf) >= HUGE_BUF) |
|
|
652 | { |
626 | 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", |
627 | 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); |
628 | } |
659 | } |
629 | <MESSAGE>.* {strcat(msgbuf, yytext); strcat(msgbuf,"\n"); } |
660 | <MESSAGE>.* {strcat(msgbuf, yytext); strcat(msgbuf,"\n"); } |
630 | |
661 | |
631 | ^lore{WS}$ { BEGIN( LORE ); lorebuf[0]='\0'; } |
662 | ^lore{WS}$ { BEGIN( LORE ); lorebuf[0]='\0'; } |
632 | <LORE>^endlore{WS}$ { BEGIN( INITIAL ); |
663 | <LORE>^endlore{WS}$ { BEGIN( INITIAL ); |
… | |
… | |
834 | ^neutral{S} SET_OR_CLEAR_FLAG(op, FLAG_NEUTRAL, IVAL); |
865 | ^neutral{S} SET_OR_CLEAR_FLAG(op, FLAG_NEUTRAL, IVAL); |
835 | ^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); |
836 | ^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); |
837 | ^friendly{S} { if (IVAL) { |
868 | ^friendly{S} { if (IVAL) { |
838 | SET_FLAG(op, FLAG_FRIENDLY); |
869 | SET_FLAG(op, FLAG_FRIENDLY); |
839 | if (op->type != PLAYER) { |
870 | if (op->type != PLAYER) |
840 | LOG(llevDebug," Adding friendly object %s.\n",op->name); |
|
|
841 | add_friendly_object(op); |
871 | add_friendly_object (op); |
842 | } |
|
|
843 | } |
872 | } |
844 | else CLEAR_FLAG(op, FLAG_FRIENDLY); |
873 | else CLEAR_FLAG(op, FLAG_FRIENDLY); |
845 | } |
874 | } |
846 | ^generator{S} SET_OR_CLEAR_FLAG(op, FLAG_GENERATOR, IVAL); |
875 | ^generator{S} SET_OR_CLEAR_FLAG(op, FLAG_GENERATOR, IVAL); |
847 | ^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); |
… | |
… | |
1545 | |
1574 | |
1546 | strcpy(retbuf,""); |
1575 | strcpy(retbuf,""); |
1547 | strcpy(retbuf_all," all"); |
1576 | strcpy(retbuf_all," all"); |
1548 | |
1577 | |
1549 | /* Quick check, and probably fairly common */ |
1578 | /* Quick check, and probably fairly common */ |
1550 | if (mt == MOVE_ALL) return retbuf_all; |
1579 | if (mt == MOVE_ALL) return retbuf_all+1; |
1551 | if (mt == 0) { |
1580 | if (mt == 0) { |
1552 | strcpy(retbuf,"0"); |
1581 | strcpy(retbuf,"0"); |
1553 | return retbuf; |
1582 | return retbuf; |
1554 | } |
1583 | } |
1555 | |
1584 | |
… | |
… | |
1570 | /* Basically, if there is a single negation, return it, eg |
1599 | /* Basically, if there is a single negation, return it, eg |
1571 | * 'all -swim'. But more than that, just return the |
1600 | * 'all -swim'. But more than that, just return the |
1572 | * enumerated values. It doesn't make sense to return |
1601 | * enumerated values. It doesn't make sense to return |
1573 | * 'all -walk -fly_low' - it is shorter to return 'fly_high swim' |
1602 | * 'all -walk -fly_low' - it is shorter to return 'fly_high swim' |
1574 | */ |
1603 | */ |
1575 | if (all_count <=1) return retbuf_all; |
1604 | if (all_count <=1) return retbuf_all+1; |
1576 | else return retbuf; |
1605 | else return retbuf+1; |
1577 | } |
1606 | } |
1578 | |
1607 | |
1579 | |
1608 | |
1580 | /* |
1609 | /* |
1581 | * Returns a pointer to a static string which contains all variables |
1610 | * Returns a pointer to a static string which contains all variables |
… | |
… | |
1767 | if(op->stats.maxgrace!=op2->stats.maxgrace) |
1796 | if(op->stats.maxgrace!=op2->stats.maxgrace) |
1768 | FAST_SAVE_LONG(fastbuf,"maxgrace ",op->stats.maxgrace,9); |
1797 | FAST_SAVE_LONG(fastbuf,"maxgrace ",op->stats.maxgrace,9); |
1769 | |
1798 | |
1770 | if(op->stats.exp!=op2->stats.exp) { |
1799 | if(op->stats.exp!=op2->stats.exp) { |
1771 | #ifndef WIN32 |
1800 | #ifndef WIN32 |
1772 | sprintf(buf2,"%lld\n", op->stats.exp); |
1801 | sprintf(buf2,"%lld", op->stats.exp); |
1773 | #else |
1802 | #else |
1774 | sprintf(buf2,"%I64d\n", op->stats.exp); |
1803 | sprintf(buf2,"%I64d", op->stats.exp); |
1775 | #endif |
1804 | #endif |
1776 | ADD_STRINGLINE_ENTRY(fastbuf,"exp ", buf2, 4); |
1805 | ADD_STRINGLINE_ENTRY(fastbuf,"exp ", buf2, 4); |
1777 | } |
1806 | } |
1778 | |
1807 | |
1779 | if(op->perm_exp!=op2->perm_exp) { |
1808 | if(op->perm_exp!=op2->perm_exp) { |
1780 | #ifndef WIN32 |
1809 | #ifndef WIN32 |
1781 | sprintf(buf2,"%lld\n", op->perm_exp); |
1810 | sprintf(buf2,"%lld", op->perm_exp); |
1782 | #else |
1811 | #else |
1783 | sprintf(buf2,"%I64d\n", op->perm_exp); |
1812 | sprintf(buf2,"%I64d", op->perm_exp); |
1784 | #endif |
1813 | #endif |
1785 | ADD_STRINGLINE_ENTRY(fastbuf,"perm_exp ", buf2, 9); |
1814 | ADD_STRINGLINE_ENTRY(fastbuf,"perm_exp ", buf2, 9); |
1786 | } |
1815 | } |
1787 | |
1816 | |
1788 | if(op->expmul!=op2->expmul) |
1817 | if(op->expmul!=op2->expmul) |
… | |
… | |
1933 | * save (say to a temp map, where we don't care about strings), |
1962 | * save (say to a temp map, where we don't care about strings), |
1934 | * or a slower save/dm dump, where printing out strings is handy. |
1963 | * or a slower save/dm dump, where printing out strings is handy. |
1935 | */ |
1964 | */ |
1936 | if (op->move_type != op2->move_type) { |
1965 | if (op->move_type != op2->move_type) { |
1937 | /*FAST_SAVE_LONG(fastbuf,"move_type ",op->move_type,10)*/ |
1966 | /*FAST_SAVE_LONG(fastbuf,"move_type ",op->move_type,10)*/ |
1938 | ADD_STRINGLINE_ENTRY(fastbuf,"move_type ", |
1967 | ADD_STRINGLINE_ENTRY(fastbuf,"move_type ", |
1939 | get_string_move_type(op->move_type), |
1968 | get_string_move_type(op->move_type), |
1940 | 10); |
1969 | 10); |
1941 | } |
1970 | } |
1942 | if (op->move_block != op2->move_block) { |
1971 | if (op->move_block != op2->move_block) { |
1943 | /*FAST_SAVE_LONG(fastbuf,"move_block ",op->move_block,11)*/ |
1972 | /*FAST_SAVE_LONG(fastbuf,"move_block ",op->move_block,11)*/ |
1944 | ADD_STRINGLINE_ENTRY(fastbuf,"move_block ", |
1973 | ADD_STRINGLINE_ENTRY(fastbuf,"move_block ", |
1945 | get_string_move_type(op->move_block), |
1974 | get_string_move_type(op->move_block), |
1946 | 11); |
1975 | 11); |
1947 | } |
1976 | } |
1948 | if (op->move_allow != op2->move_allow) { |
1977 | if (op->move_allow != op2->move_allow) { |
1949 | /*FAST_SAVE_LONG(fastbuf,"move_allow ",op->move_allow,11);*/ |
1978 | /*FAST_SAVE_LONG(fastbuf,"move_allow ",op->move_allow,11);*/ |
1950 | ADD_STRINGLINE_ENTRY(fastbuf,"move_allow ", |
1979 | ADD_STRINGLINE_ENTRY(fastbuf,"move_allow ", |
1951 | get_string_move_type(op->move_allow), |
1980 | get_string_move_type(op->move_allow), |
1952 | 11); |
1981 | 11); |
1953 | } |
1982 | } |
1954 | if (op->move_on != op2->move_on) { |
1983 | if (op->move_on != op2->move_on) { |
1955 | /*FAST_SAVE_LONG(fastbuf,"move_on ",op->move_on,8);*/ |
1984 | /*FAST_SAVE_LONG(fastbuf,"move_on ",op->move_on,8);*/ |
1956 | ADD_STRINGLINE_ENTRY(fastbuf,"move_on ", |
1985 | ADD_STRINGLINE_ENTRY(fastbuf,"move_on ", |
1957 | get_string_move_type(op->move_on), |
1986 | get_string_move_type(op->move_on), |
1958 | 8); |
1987 | 8); |
1959 | } |
1988 | } |
1960 | if (op->move_off != op2->move_off) { |
1989 | if (op->move_off != op2->move_off) { |
1961 | /*FAST_SAVE_LONG(fastbuf,"move_off ",op->move_off,9);*/ |
1990 | /*FAST_SAVE_LONG(fastbuf,"move_off ",op->move_off,9);*/ |
1962 | ADD_STRINGLINE_ENTRY(fastbuf,"move_off ", |
1991 | ADD_STRINGLINE_ENTRY(fastbuf,"move_off ", |
1963 | get_string_move_type(op->move_off), |
1992 | get_string_move_type(op->move_off), |
1964 | 9); |
1993 | 9); |
1965 | } |
1994 | } |
1966 | if (op->move_slow != op2->move_slow) { |
1995 | if (op->move_slow != op2->move_slow) { |
1967 | /*FAST_SAVE_LONG(fastbuf,"move_slow ",op->move_slow,10);*/ |
1996 | /*FAST_SAVE_LONG(fastbuf,"move_slow ",op->move_slow,10);*/ |
1968 | ADD_STRINGLINE_ENTRY(fastbuf,"move_slow ", |
1997 | ADD_STRINGLINE_ENTRY(fastbuf,"move_slow ", |
1969 | get_string_move_type(op->move_slow), |
1998 | get_string_move_type(op->move_slow), |
1970 | 10); |
1999 | 10); |
1971 | } |
2000 | } |
1972 | |
2001 | |
1973 | if (op->move_slow_penalty != op2->move_slow_penalty) { |
2002 | if (op->move_slow_penalty != op2->move_slow_penalty) { |