void prim_stats(PRIM_PROTOTYPE) { /* A WhiteFire special. :) */ CHECKOP(1); oper1 = POP(); if (mlev < 3) abort_interp("Requires Mucker Level 3."); if (!valid_player(oper1) && (oper1->data.objref != NOTHING)) abort_interp("non-player argument (1)"); ref = oper1->data.objref; CLEAR(oper1); { dbref i; int rooms, exits, things, players, programs, garbage; /* tmp, ref */ rooms = exits = things = players = programs = garbage = 0; for (i = 0; i < db_top; i++) { if (ref == NOTHING || OWNER(i) == ref) { switch (Typeof(i)) { case TYPE_ROOM: rooms++; break; case TYPE_EXIT: exits++; break; case TYPE_THING: things++; break; case TYPE_PLAYER: players++; break; case TYPE_PROGRAM: programs++; break; case TYPE_GARBAGE: garbage++; break; } } } ref = rooms + exits + things + players + programs + garbage; CHECKOFLOW(7); PushInt(ref); PushInt(rooms); PushInt(exits); PushInt(things); PushInt(programs); PushInt(players); PushInt(garbage); /* push results */ } }
void prim_descriptors(PRIM_PROTOTYPE) { int mydescr, mycount = 0; int di, dcount, descr; int* darr; CHECKOP(1); oper1 = POP(); if (mlev < LM3) abort_interp("M3 prim"); if (oper1->type != PROG_OBJECT) abort_interp("Argument not a dbref"); if (oper1->data.objref != NOTHING && !valid_object(oper1)) abort_interp("Bad dbref"); ref = oper1->data.objref; if ((ref != NOTHING) && (!valid_player(oper1))) abort_interp("Non-player argument"); CLEAR(oper1); CHECKOP(0); if (ref == NOTHING) { for (result = pcount(); result; result--) { CHECKOFLOW(1); mydescr = pdescr(result); PushInt(mydescr); mycount++; } } else { if (Typeof(ref) == TYPE_PLAYER) { darr = DBFETCH(ref)->sp.player.descrs; dcount = DBFETCH(ref)->sp.player.descr_count; if (!darr) dcount = 0; } else { darr = NULL; dcount = 0; } for (di = 0; di < dcount; di++) { CHECKOFLOW(1); descr = index_descr(darr[di]); PushInt(descr); mycount++; } } CHECKOFLOW(1); PushInt(mycount); }
void prim_descr_setuser(PRIM_PROTOTYPE) { char *ptr; CHECKOP(3); oper3 = POP(); oper2 = POP(); oper1 = POP(); if (mlev < (tp_compatible_muf ? LMAGE : LARCH)) abort_interp(tp_compatible_muf ? "Mage prim" : "Arch prim"); if (oper1->type != PROG_INTEGER) abort_interp("Integer descriptor number expected (1)"); if (oper2->type != PROG_OBJECT) abort_interp("Player dbref expected (2)"); ref = oper2->data.objref; if (ref != NOTHING && !valid_player(oper2)) abort_interp("Player dbref expected (2)"); if (oper3->type != PROG_STRING) abort_interp("Password string expected"); ptr = oper3->data.string? oper3->data.string->data : ""; if ((ref != NOTHING) && DBFETCH(ref)->sp.player.password && (*DBFETCH(ref)->sp.player.password) && strcmp(ptr, DBFETCH(ref)->sp.player.password) ) abort_interp("Incorrect password"); if (ref != NOTHING) { log_status("SUID: %d %s to %s(%d)\n", oper1->data.number, unparse_object(MAN, player), NAME(ref), ref); } tmp = oper1->data.number; CLEAR(oper1); CLEAR(oper2); CLEAR(oper3); result = pset_user(tmp, ref); PushInt(result); }
std::string Condition::getName(bool tip, NameFlags::Value flags, int recursion) const { if (!tip) { return (type < scen.pergame->max_condition_types) ? types[type] : "Unknown!"; } else { std::string stype = std::string(""); std::ostringstream convert; switch (type) { case ConditionType::None: // Let this act like a separator convert << " "; stype.append(convert.str()); break; case ConditionType::BringObjectToArea: convert << get_unit_full_name(object) << " " << object; convert << " is" << areaName(); stype.append(convert.str()); break; case ConditionType::BringObjectToObject: convert << get_unit_full_name(object) << " " << object << " is next to unit " << get_unit_full_name(u_loc) << " " << u_loc; stype.append(convert.str()); break; case ConditionType::OwnObjects: case ConditionType::OwnFewerObjects: case ConditionType::ObjectsInArea: { // we define some variables in this block, therefore need scope as we are also in a case if (valid_player()) { convert << playerPronoun(player) << " has "; } switch (type) { case ConditionType::OwnObjects: case ConditionType::ObjectsInArea: if (amount == 0) { convert << "any number of"; } else { convert << "at least " << amount; } break; case ConditionType::OwnFewerObjects: if (amount == 0) { convert << "no"; } else { convert << "at most " << amount; } break; } if (valid_unit_spec()) { std::string un(wstringToString(pUnit->name())); if (amount > 1 && !un.empty() && *un.rbegin() != 's' && !replaced(un, "man", "men")) { convert << " " << un << "s"; } else { convert << " " << un; } } else { if (amount != 1) { convert << " units"; } else { convert << " unit"; } } convert << areaName(); stype.append(convert.str()); } break; case ConditionType::DestroyObject: convert << get_unit_full_name(object) << " is killed"; stype.append(convert.str()); break; case ConditionType::CaptureObject: convert << playerPronoun(player) << " captured " << get_unit_full_name(object); stype.append(convert.str()); break; case ConditionType::AccumulateAttribute: switch (res_type) { case 0: // Food accumulated convert << playerPronoun(player) << " has " << amount << " food"; break; case 1: // Wood accumulated convert << playerPronoun(player) << " has " << amount << " wood"; break; case 2: // Stone accumulated convert << playerPronoun(player) << " has " << amount << " stone"; break; case 3: // Gold accumulated convert << playerPronoun(player) << " has " << amount << " gold"; break; case 20: // Units killed if (amount == 1) { convert << playerPronoun(player) << " kills a unit"; } else { convert << playerPronoun(player) << " has killed " << amount << " units"; } break; case 44: // Kill ratio if (amount == 0) { convert << playerPronoun(player) << " has equal kills and deaths"; } else if (amount == 1) { convert << playerPronoun(player) << " has killed one more than lost"; } else if (amount > 0) { convert << playerPronoun(player) << " has " << amount << " more kills than deaths"; } else if (amount == -1) { convert << playerPronoun(player) << " has lost one more unit than has killed"; } else { convert << playerPronoun(player) << " has " << -amount << " more deaths than kills"; } break; default: //convert << types_short[type]; if (res_type >= 0) { const Link * list = esdata.resources.head(); for (int i=0; list; list = list->next(), i++) { if (i == res_type) { std::wstring resname(list->name()); convert << playerPronoun(player) << "'s "; convert << std::string( resname.begin(), resname.end()); convert << " >= " << amount; break; } } } break; } stype.append(convert.str()); break; case ConditionType::ResearchTehcnology: if (valid_technology_spec()) { convert << playerPronoun(player) << " has tech "; std::wstring techname(pTech->name()); convert << std::string( techname.begin(), techname.end()); convert << " researched"; } else { convert << "INVALID"; } stype.append(convert.str()); break; case ConditionType::ResearchingTechnology: if (pTech && pTech->id()) { convert << playerPronoun(player) << " is researching "; std::wstring techname(pTech->name()); convert << std::string( techname.begin(), techname.end()); } else { convert << "INVALID"; } stype.append(convert.str()); break; case ConditionType::Timer: convert << time_string(timer) << " has passed"; stype.append(convert.str()); break; case ConditionType::ObjectSelected: convert << "selected unit " << object; convert << " (" << get_unit_full_name(object) << ")"; stype.append(convert.str()); break; case ConditionType::AISignal: switch (ai_signal) { case -1034: convert << "singleplayer / cheats enabled"; break; case -1036: convert << "starting resources set to standard"; break; case -1039: convert << "regicide"; break; case -1040: convert << "deathmatch"; break; case -70850: convert << "one-click garrison"; break; default: if (ai_signal >= -518 && ai_signal <= -7) { int signal = ai_signal + 518; int taunt_player = signal / 64; int taunt_set_id = signal % 64; convert << "player " << taunt_player + 1 << " taunted " << taunt_set[taunt_set_id]; } else if (ai_signal >= -774 && ai_signal <= -519) { convert << "AI goal " << ai_signal + 774 << " achieved"; } else { convert << "AI signalled " << ai_signal; } } stype.append(convert.str()); break; case ConditionType::ObjectVisible: convert << "unit " << object; convert << " (" << get_unit_full_name(object) << ") is visible"; stype.append(convert.str()); break; case ConditionType::PlayerDefeated: if (player == 0) { convert << "Gaia"; } else { convert << playerPronoun(player); } convert << " is defeated"; stype.append(convert.str()); break; case ConditionType::ObjectHasTarget: convert << "unit " << object << " (" << get_unit_full_name(object) << ") is targetting"; if (null_location_unit()) { convert << " something"; } else { convert << " " << u_loc << " (" << get_unit_full_name(u_loc) << ")"; } stype.append(convert.str()); break; case ConditionType::UnitsGarrisoned: if (amount == 1) { convert << "unit " << object << " (" << get_unit_full_name(object) << ") has " << amount << " units garrisoned"; } else { convert << "unit " << object << " (" << get_unit_full_name(object) << ") has one unit garrisoned"; } stype.append(convert.str()); break; case ConditionType::DifficultyLevel: convert << "difficulty is "; switch (amount) { case DifficultyLevel::Hardest: convert << "Hardest"; break; case DifficultyLevel::Hard: convert << "Hard"; break; case DifficultyLevel::Moderate: convert << "Moderate"; break; case DifficultyLevel::Standard: convert << "Standard"; break; case DifficultyLevel::Easiest: convert << "Easiest"; break; } stype.append(convert.str()); break; case ConditionType::UnitsQueuedPastPopCap_SWGB: if (valid_player()) { convert << playerPronoun(player) << " has " << amount << " units queued past the pop cap"; } else { convert << "INVALID"; } stype.append(convert.str()); break; case ConditionType::OwnFewerFoundations_SWGB: // Chance_HD: switch (scen.game) { case AOHD: case AOF: case AOHD4: case AOF4: case AOHD6: case AOF6: convert << amount << "% chance "; stype.append(convert.str()); break; case SWGB: case SWGBCC: if (valid_player()) { convert << playerPronoun(player) << " has "; } if (amount == 0) { convert << "no"; } else { convert << "at most " << amount; } if (valid_unit_spec()) { std::string un(wstringToString(pUnit->name())); if (amount > 1 && !un.empty() && *un.rbegin() != 's' && !replaced(un, "man", "men")) { convert << " " << un << " foundations"; } else { convert << " " << un << " foundation"; } } else { if (amount != 1) { convert << " foundations"; } else { convert << " foundation"; } } convert << areaName(); stype.append(convert.str()); break; default: convert << amount << "UNKNOWN CONDITION"; stype.append(convert.str()); } break; default: stype.append((type < scen.pergame->max_condition_types) ? types_short[type] : "Unknown!"); } return flags&NameFlags::LIMITLEN?stype.substr(0,MAX_CHARS):stype; } }