1 | /* |
1 | /* |
2 | * static char *rcsid_c_misc_c = |
2 | * static char *rcsid_c_misc_c = |
3 | * "$Id: c_misc.C,v 1.4 2006/08/30 16:30:37 root Exp $"; |
3 | * "$Id: c_misc.C,v 1.5 2006/09/03 00:18:42 root Exp $"; |
4 | */ |
4 | */ |
5 | |
5 | |
6 | /* |
6 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
7 | CrossFire, A Multiplayer game for X-windows |
8 | |
8 | |
… | |
… | |
342 | chars = (chars_names *) realloc(chars, num_players*sizeof(chars_names)); |
342 | chars = (chars_names *) realloc(chars, num_players*sizeof(chars_names)); |
343 | if (chars == NULL) { |
343 | if (chars == NULL) { |
344 | new_draw_info(NDI_UNIQUE, 0, op, "who failed - out of memory!"); |
344 | new_draw_info(NDI_UNIQUE, 0, op, "who failed - out of memory!"); |
345 | return 0; |
345 | return 0; |
346 | } |
346 | } |
347 | sprintf(chars[num_players-1].namebuf, "%s", pl->ob->name); |
347 | sprintf(chars[num_players-1].namebuf, "%s", &pl->ob->name); |
348 | chars[num_players-1].login_order = num_players; |
348 | chars[num_players-1].login_order = num_players; |
349 | /*Check for WIZ's & AFK's*/ |
349 | /*Check for WIZ's & AFK's*/ |
350 | if (QUERY_FLAG(pl->ob,FLAG_WIZ)) |
350 | if (QUERY_FLAG(pl->ob,FLAG_WIZ)) |
351 | num_wiz++; |
351 | num_wiz++; |
352 | if (QUERY_FLAG(pl->ob,FLAG_AFK)) |
352 | if (QUERY_FLAG(pl->ob,FLAG_AFK)) |
… | |
… | |
496 | { |
496 | { |
497 | map_info(op,params); |
497 | map_info(op,params); |
498 | return 1; |
498 | return 1; |
499 | } |
499 | } |
500 | |
500 | |
501 | int command_strings (object *op, char *params) |
|
|
502 | { |
|
|
503 | ss_dump_statistics(); |
|
|
504 | new_draw_info(NDI_UNIQUE, 0,op,errmsg); |
|
|
505 | new_draw_info(NDI_UNIQUE, 0,op,ss_dump_table(2)); |
|
|
506 | return 1; |
|
|
507 | } |
|
|
508 | |
|
|
509 | #ifdef DEBUG |
|
|
510 | int command_sstable (object *op, char *params) |
|
|
511 | { |
|
|
512 | ss_dump_table(1); |
|
|
513 | return 1; |
|
|
514 | } |
|
|
515 | #endif |
|
|
516 | |
|
|
517 | int command_time (object *op, char *params) |
501 | int command_time (object *op, char *params) |
518 | { |
502 | { |
519 | print_tod (op); |
503 | print_tod (op); |
520 | return 1; |
504 | return 1; |
521 | } |
505 | } |
… | |
… | |
725 | int command_dumpallarchetypes (object *op, char *params) |
709 | int command_dumpallarchetypes (object *op, char *params) |
726 | { |
710 | { |
727 | dump_all_archetypes(); |
711 | dump_all_archetypes(); |
728 | return 0; |
712 | return 0; |
729 | } |
713 | } |
730 | |
|
|
731 | int command_ssdumptable (object *op, char *params) |
|
|
732 | { |
|
|
733 | (void) ss_dump_table(1); |
|
|
734 | return 0; |
|
|
735 | } |
|
|
736 | |
714 | |
737 | int command_dumpmap (object *op, char *params) |
715 | int command_dumpmap (object *op, char *params) |
738 | { |
716 | { |
739 | if(op) |
717 | if(op) |
740 | dump_map(op->map); |
718 | dump_map(op->map); |
… | |
… | |
1057 | next = obl->next; |
1035 | next = obl->next; |
1058 | if (get_owner(ob) == op) { |
1036 | if (get_owner(ob) == op) { |
1059 | if (target ==0) { |
1037 | if (target ==0) { |
1060 | if (counter==0) |
1038 | if (counter==0) |
1061 | new_draw_info(NDI_UNIQUE, 0, op, "Pets:"); |
1039 | new_draw_info(NDI_UNIQUE, 0, op, "Pets:"); |
1062 | new_draw_info_format(NDI_UNIQUE, 0, op, "%d %s - level %d", ++counter, ob->name, ob->level ); |
1040 | new_draw_info_format(NDI_UNIQUE, 0, op, "%d %s - level %d", ++counter, &ob->name, ob->level ); |
1063 | } |
1041 | } |
1064 | else if (!have_shown_pet && ++counter==target) { |
1042 | else if (!have_shown_pet && ++counter==target) { |
1065 | new_draw_info_format(NDI_UNIQUE, 0, op, "level %d %s", ob->level, ob->name); |
1043 | new_draw_info_format(NDI_UNIQUE, 0, op, "level %d %s", ob->level, &ob->name); |
1066 | new_draw_info_format(NDI_UNIQUE, 0, op, "%d/%d HP, %d/%d SP", |
1044 | new_draw_info_format(NDI_UNIQUE, 0, op, "%d/%d HP, %d/%d SP", |
1067 | ob->stats.hp, ob->stats.maxhp, ob->stats.sp, ob->stats.maxsp); |
1045 | ob->stats.hp, ob->stats.maxhp, ob->stats.sp, ob->stats.maxsp); |
1068 | /* this is not a nice way to do this, it should be made to be more like the statistics command */ |
1046 | /* this is not a nice way to do this, it should be made to be more like the statistics command */ |
1069 | new_draw_info_format(NDI_UNIQUE, 0, op, "Str %d", ob->stats.Str); |
1047 | new_draw_info_format(NDI_UNIQUE, 0, op, "Str %d", ob->stats.Str); |
1070 | new_draw_info_format(NDI_UNIQUE, 0, op, "Dex %d", ob->stats.Dex); |
1048 | new_draw_info_format(NDI_UNIQUE, 0, op, "Dex %d", ob->stats.Dex); |
… | |
… | |
1434 | |
1412 | |
1435 | if(!check_name(op->contr,op->contr->write_buf+1)) { |
1413 | if(!check_name(op->contr,op->contr->write_buf+1)) { |
1436 | get_name(op); |
1414 | get_name(op); |
1437 | return; |
1415 | return; |
1438 | } |
1416 | } |
1439 | FREE_AND_COPY(op->name, op->contr->write_buf+1); |
1417 | op->name = op->contr->write_buf + 1; |
1440 | FREE_AND_COPY(op->name_pl, op->contr->write_buf+1); |
1418 | op->name_pl = op->contr->write_buf + 1; |
1441 | new_draw_info(NDI_UNIQUE, 0,op,op->contr->write_buf); |
1419 | new_draw_info(NDI_UNIQUE, 0,op,op->contr->write_buf); |
1442 | op->contr->name_changed=1; |
1420 | op->contr->name_changed=1; |
1443 | get_password(op); |
1421 | get_password(op); |
1444 | } |
1422 | } |
1445 | |
1423 | |
… | |
… | |
1451 | return; |
1429 | return; |
1452 | } |
1430 | } |
1453 | new_draw_info(NDI_UNIQUE, 0,op," "); /* To hide the password better */ |
1431 | new_draw_info(NDI_UNIQUE, 0,op," "); /* To hide the password better */ |
1454 | |
1432 | |
1455 | if (checkbanned(op->name, op->contr->socket.host)) { |
1433 | if (checkbanned(op->name, op->contr->socket.host)) { |
1456 | LOG(llevInfo, "Banned player tried to add: [%s@%s]\n", op->name, op->contr->socket.host); |
1434 | LOG(llevInfo, "Banned player tried to add: [%s@%s]\n", &op->name, op->contr->socket.host); |
1457 | new_draw_info(NDI_UNIQUE|NDI_RED, 0, op, "You are not allowed to play."); |
1435 | new_draw_info(NDI_UNIQUE|NDI_RED, 0, op, "You are not allowed to play."); |
1458 | get_name(op); |
1436 | get_name(op); |
1459 | return; |
1437 | return; |
1460 | } |
1438 | } |
1461 | |
1439 | |
… | |
… | |
1656 | new_draw_info(NDI_UNIQUE, 0, op, "Couldn't find any suitable pets to kill.\n"); |
1634 | new_draw_info(NDI_UNIQUE, 0, op, "Couldn't find any suitable pets to kill.\n"); |
1657 | } |
1635 | } |
1658 | return 0; |
1636 | return 0; |
1659 | } |
1637 | } |
1660 | |
1638 | |
1661 | /** |
|
|
1662 | * Displays all non start/end tags for specified quest. |
|
|
1663 | **/ |
|
|
1664 | static void display_quest_details( object* pl, object* quest ) |
|
|
1665 | { |
|
|
1666 | /* object* item; */ |
|
|
1667 | |
|
|
1668 | new_draw_info_format( NDI_WHITE, 0, pl, "Quest: %s\n%s\n", |
|
|
1669 | quest_get_name( quest ), |
|
|
1670 | quest->lore ? quest->lore : "(no description available)" ); |
|
|
1671 | /* |
|
|
1672 | for ( item = pl->inv; item; item = item->below ) |
|
|
1673 | { |
|
|
1674 | if ( ( item != quest ) |
|
|
1675 | && ( quest_is_quest_marker( item ) ) |
|
|
1676 | && ( quest_is_same_quest( quest->slaying, item->slaying ) ) |
|
|
1677 | && ( item->lore ) ) |
|
|
1678 | { |
|
|
1679 | new_draw_info( NDI_WHITE, 0, pl, item->lore ); |
|
|
1680 | new_draw_info( NDI_WHITE, 0, pl, "------\n" ); |
|
|
1681 | } |
|
|
1682 | } |
|
|
1683 | */ |
|
|
1684 | } |
|
|
1685 | |
|
|
1686 | /** |
|
|
1687 | * Displays quest information to player. |
|
|
1688 | * Acceptable parameters: |
|
|
1689 | * * finished => finished quests only |
|
|
1690 | * * <name> => only this particular quest, finished or not, with details |
|
|
1691 | * * nothing => all current quests |
|
|
1692 | * |
|
|
1693 | * For current quests, will display either the lore of the non start tags, |
|
|
1694 | * or the lore of start tag if no other tag. |
|
|
1695 | **/ |
|
|
1696 | int command_quests( object *pl, char *params ) |
|
|
1697 | { |
|
|
1698 | object* item; |
|
|
1699 | |
|
|
1700 | if ( params && !strcmp( params, "finished" ) ) |
|
|
1701 | { |
|
|
1702 | new_draw_info( NDI_WHITE, 0, pl, "Completed quests:\n" ); |
|
|
1703 | for ( item = pl->inv; item; item = item->below ) |
|
|
1704 | { |
|
|
1705 | if ( quest_is_quest_marker( item, 0 ) ) |
|
|
1706 | { |
|
|
1707 | new_draw_info( NDI_WHITE, 0, pl, quest_get_name( item ) ); |
|
|
1708 | new_draw_info( NDI_WHITE, 0, pl, "\n" ); |
|
|
1709 | } |
|
|
1710 | } |
|
|
1711 | return 1; |
|
|
1712 | } |
|
|
1713 | |
|
|
1714 | if ( params ) |
|
|
1715 | { |
|
|
1716 | for ( item = pl->inv; item; item = item->below ) |
|
|
1717 | { |
|
|
1718 | if ( quest_is_quest_marker( item, 0 ) |
|
|
1719 | && !strcmp( quest_get_name( item ), params ) ) |
|
|
1720 | { |
|
|
1721 | display_quest_details( pl, item ); |
|
|
1722 | } |
|
|
1723 | } |
|
|
1724 | return 1; |
|
|
1725 | } |
|
|
1726 | |
|
|
1727 | /*Display current quests */ |
|
|
1728 | new_draw_info( NDI_WHITE, 0, pl, "Current quests:\n" ); |
|
|
1729 | for ( item = pl->inv; item; item = item->below ) |
|
|
1730 | { |
|
|
1731 | if ( quest_is_quest_marker( item, 0 ) |
|
|
1732 | && quest_is_in_progress( item, 0 ) ) |
|
|
1733 | { |
|
|
1734 | new_draw_info( NDI_WHITE, 0, pl, quest_get_name( item ) ); |
|
|
1735 | new_draw_info( NDI_WHITE, 0, pl, "\n" ); |
|
|
1736 | } |
|
|
1737 | } |
|
|
1738 | return 1; |
|
|
1739 | } |
|
|