3 * =============================================================================
5 * Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved.
6 * =============================================================================
8 * This program is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU General Public License, version 3.0, as published by the
10 * Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * You should have received a copy of the GNU General Public License along with
18 * this program. If not, see <http://www.gnu.org/licenses/>.
20 * As a special exception, AlliedModders LLC gives you permission to link the
21 * code of this program (as well as its derivative works) to "Half-Life 2," the
22 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
23 * by the Valve Corporation. You must obey the GNU General Public License in
24 * all respects for all other code used. Additionally, AlliedModders LLC grants
25 * this exception to all derivative works. AlliedModders LLC defines further
26 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
27 * or <http://www.sourcemod.net/license.php>.
32 #include "ConCmdManager.h"
33 #include "sm_srvcmds.h"
34 #include "AdminCache.h"
35 #include "sm_stringutil.h"
36 #include "PlayerManager.h"
37 #include "Translator.h"
38 #include "HalfLife2.h"
39 #include "ChatTriggers.h"
41 ConCmdManager g_ConCmds;
43 SH_DECL_HOOK0_void(ConCommand, Dispatch, SH_NOATTRIB, false);
44 SH_DECL_HOOK1_void(IServerGameClients, SetCommandClient, SH_NOATTRIB, false, int);
52 typedef List<PlCmdInfo> CmdList;
54 void AddToPlCmdList(CmdList *pList, const PlCmdInfo &info);
56 ConCmdManager::ConCmdManager() : m_Strings(1024)
58 m_pCmds = sm_trie_create();
59 m_pCmdGrps = sm_trie_create();
63 ConCmdManager::~ConCmdManager()
65 sm_trie_destroy(m_pCmds);
66 sm_trie_destroy(m_pCmdGrps);
69 void ConCmdManager::OnSourceModAllInitialized()
71 g_PluginSys.AddPluginsListener(this);
72 g_RootMenu.AddRootConsoleCommand("cmds", "List console commands", this);
73 SH_ADD_HOOK_MEMFUNC(IServerGameClients, SetCommandClient, serverClients, this, &ConCmdManager::SetCommandClient, false);
76 void ConCmdManager::OnSourceModShutdown()
78 /* All commands should already be removed by the time we're done */
79 SH_REMOVE_HOOK_MEMFUNC(IServerGameClients, SetCommandClient, serverClients, this, &ConCmdManager::SetCommandClient, false);
80 g_RootMenu.RemoveRootConsoleCommand("cmds", this);
83 void ConCmdManager::RemoveConCmds(List<CmdHook *> &cmdlist, IPluginContext *pContext)
85 List<CmdHook *>::iterator iter = cmdlist.begin();
88 while (iter != cmdlist.end())
91 if (pHook->pf->GetParentContext() == pContext)
95 iter = cmdlist.erase(iter);
102 void ConCmdManager::OnPluginDestroyed(IPlugin *plugin)
105 List<ConCmdInfo *> removed;
106 if (plugin->GetProperty("CommandList", (void **)&pList, true))
108 IPluginContext *pContext = plugin->GetBaseContext();
109 CmdList::iterator iter;
111 * Only bother if there's an actual command list on this plugin...
113 for (iter=pList->begin();
117 PlCmdInfo &cmd = (*iter);
118 ConCmdInfo *pInfo = cmd.pInfo;
120 /* Has this chain already been fully cleaned/removed? */
121 if (removed.find(pInfo) != removed.end())
126 /* Remove any hooks from us on this command */
127 RemoveConCmds(pInfo->conhooks, pContext);
128 RemoveConCmds(pInfo->srvhooks, pContext);
130 /* See if there are still hooks */
131 if (pInfo->srvhooks.size())
135 if (pInfo->conhooks.size())
140 /* Remove the command, it should be safe now */
142 removed.push_back(pInfo);
148 void CommandCallback()
150 g_ConCmds.InternalDispatch();
153 void ConCmdManager::SetCommandClient(int client)
155 m_CmdClient = client + 1;
158 ResultType ConCmdManager::DispatchClientCommand(int client, const char *cmd, int args, ResultType type)
161 if (sm_trie_retrieve(m_pCmds, cmd, (void **)&pInfo))
163 cell_t result = type;
164 cell_t tempres = result;
165 List<CmdHook *>::iterator iter;
167 for (iter=pInfo->conhooks.begin();
168 iter!=pInfo->conhooks.end();
172 if (!pHook->pf->IsRunnable())
176 if (pHook->pAdmin && !CheckAccess(client, cmd, pHook->pAdmin))
178 if (result < Pl_Handled)
184 pHook->pf->PushCell(client);
185 pHook->pf->PushCell(args);
186 if (pHook->pf->Execute(&tempres) == SP_ERROR_NONE)
188 if (tempres > result)
192 if (result == Pl_Stop)
198 type = (ResultType)result;
204 void ConCmdManager::InternalDispatch()
206 int client = m_CmdClient;
210 CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
211 if (!pPlayer || !pPlayer->IsConnected())
218 * Note: Console commands will EITHER go through IServerGameDLL::ClientCommand,
219 * OR this dispatch. They will NEVER go through both.
221 * Whether or not it goes through the callback is determined by FCVAR_GAMEDLL
224 strncopy(cmd, engine->Cmd_Argv(0), sizeof(cmd));
227 if (!sm_trie_retrieve(m_pCmds, cmd, (void **)&pInfo))
232 cell_t result = Pl_Continue;
233 int args = engine->Cmd_Argc() - 1;
235 List<CmdHook *>::iterator iter;
238 /* Execute server-only commands if viable */
239 if (client == 0 && pInfo->srvhooks.size())
241 cell_t tempres = result;
242 for (iter=pInfo->srvhooks.begin();
243 iter!=pInfo->srvhooks.end();
247 if (!pHook->pf->IsRunnable())
251 pHook->pf->PushCell(args);
252 if (pHook->pf->Execute(&tempres) == SP_ERROR_NONE)
254 if (tempres > result)
258 if (result == Pl_Stop)
265 /* Check if there's an early stop */
266 if (result >= Pl_Stop)
268 if (!pInfo->sourceMod)
270 RETURN_META(MRES_SUPERCEDE);
276 /* Execute console commands */
277 if (pInfo->conhooks.size())
279 cell_t tempres = result;
280 for (iter=pInfo->conhooks.begin();
281 iter!=pInfo->conhooks.end();
285 if (!pHook->pf->IsRunnable())
291 && !CheckAccess(client, cmd, pHook->pAdmin))
293 if (result < Pl_Handled)
300 /* On a listen server, sometimes the server host's client index can be set as 0.
301 * So index 1 is passed to the command callback to correct this potential problem.
303 if (client == 0 && !engine->IsDedicatedServer())
305 pHook->pf->PushCell(1);
307 pHook->pf->PushCell(client);
310 pHook->pf->PushCell(args);
311 if (pHook->pf->Execute(&tempres) == SP_ERROR_NONE)
313 if (tempres > result)
317 if (result == Pl_Stop)
325 if (result >= Pl_Handled)
327 if (!pInfo->sourceMod)
329 RETURN_META(MRES_SUPERCEDE);
335 bool ConCmdManager::CheckCommandAccess(int client, const char *cmd, FlagBits cmdflags)
337 if (cmdflags == 0 || client == 0)
342 /* If running listen server, then client 1 is the server host and should have 'root' access */
343 if (client == 1 && !engine->IsDedicatedServer())
348 CPlayer *player = g_Players.GetPlayerByIndex(client);
350 || player->GetEdict() == NULL
351 || player->IsFakeClient())
356 AdminId adm = player->GetAdminId();
357 if (adm != INVALID_ADMIN_ID)
359 FlagBits bits = g_Admins.GetAdminFlags(adm, Access_Effective);
361 /* root knows all, WHOA */
362 if ((bits & ADMFLAG_ROOT) == ADMFLAG_ROOT)
367 /* Check for overrides
368 * :TODO: is it worth optimizing this?
370 unsigned int groups = g_Admins.GetAdminGroupCount(adm);
373 bool override = false;
374 for (unsigned int i=0; i<groups; i++)
376 gid = g_Admins.GetAdminGroup(adm, i, NULL);
377 /* First get group-level override */
378 override = g_Admins.GetGroupCommandOverride(gid, cmd, Override_CommandGroup, &rule);
379 /* Now get the specific command override */
380 if (g_Admins.GetGroupCommandOverride(gid, cmd, Override_Command, &rule))
386 if (rule == Command_Allow)
389 } else if (rule == Command_Deny) {
395 /* See if our other flags match */
396 if ((bits & cmdflags) == cmdflags)
405 bool ConCmdManager::CheckAccess(int client, const char *cmd, AdminCmdInfo *pAdmin)
407 if (CheckCommandAccess(client, cmd, pAdmin->eflags))
412 edict_t *pEdict = engine->PEntityOfEntIndex(client);
414 /* If we got here, the command failed... */
416 if (g_Translator.CoreTrans(client, buffer, sizeof(buffer), "No Access", NULL, NULL)
419 snprintf(buffer, sizeof(buffer), "You do not have access to this command");
422 unsigned int replyto = g_ChatTriggers.GetReplyTo();
423 if (replyto == SM_REPLY_CONSOLE)
425 char fullbuffer[192];
426 snprintf(fullbuffer, sizeof(fullbuffer), "[SM] %s.\n", buffer);
427 engine->ClientPrintf(pEdict, fullbuffer);
428 } else if (replyto == SM_REPLY_CHAT) {
429 char fullbuffer[192];
430 snprintf(fullbuffer, sizeof(fullbuffer), "[SM] %s.", buffer);
431 g_HL2.TextMsg(client, HUD_PRINTTALK, fullbuffer);
437 bool ConCmdManager::AddConsoleCommand(IPluginFunction *pFunction,
439 const char *description,
442 ConCmdInfo *pInfo = AddOrFindCommand(name, description, flags);
449 CmdHook *pHook = new CmdHook();
451 pHook->pf = pFunction;
452 if (description && description[0])
454 pHook->helptext.assign(description);
456 pInfo->conhooks.push_back(pHook);
458 /* Add to the plugin */
460 IPlugin *pPlugin = g_PluginSys.GetPluginByCtx(pFunction->GetParentContext()->GetContext());
461 if (!pPlugin->GetProperty("CommandList", (void **)&pList))
463 pList = new CmdList();
464 pPlugin->SetProperty("CommandList", pList);
468 info.type = Cmd_Console;
470 AddToPlCmdList(pList, info);
475 bool ConCmdManager::AddAdminCommand(IPluginFunction *pFunction,
479 const char *description,
482 ConCmdInfo *pInfo = AddOrFindCommand(name, description, flags);
489 CmdHook *pHook = new CmdHook();
490 AdminCmdInfo *pAdmin = new AdminCmdInfo();
492 pHook->pf = pFunction;
493 if (description && description[0])
495 pHook->helptext.assign(description);
497 pHook->pAdmin = pAdmin;
501 if (!sm_trie_retrieve(m_pCmdGrps, group, (void **)&object))
503 grpid = m_Strings.AddString(group);
504 sm_trie_insert(m_pCmdGrps, group, (void *)grpid);
509 pAdmin->cmdGrpId = grpid;
510 pAdmin->flags = adminflags;
512 /* First get the command group override, if any */
513 bool override = g_Admins.GetCommandOverride(group,
514 Override_CommandGroup,
517 /* Next get the command override, if any */
518 if (g_Admins.GetCommandOverride(name,
525 /* Assign normal flags if there were no overrides */
528 pAdmin->eflags = pAdmin->flags;
531 /* Finally, add the hook */
532 pInfo->conhooks.push_back(pHook);
533 pInfo->admin = *(pHook->pAdmin);
534 pInfo->is_admin_set = true;
536 /* Now add to the plugin */
538 IPlugin *pPlugin = g_PluginSys.GetPluginByCtx(pFunction->GetParentContext()->GetContext());
539 if (!pPlugin->GetProperty("CommandList", (void **)&pList))
541 pList = new CmdList();
542 pPlugin->SetProperty("CommandList", pList);
546 info.type = Cmd_Admin;
548 AddToPlCmdList(pList, info);
553 bool ConCmdManager::AddServerCommand(IPluginFunction *pFunction,
555 const char *description,
559 ConCmdInfo *pInfo = AddOrFindCommand(name, description, flags);
566 CmdHook *pHook = new CmdHook();
568 pHook->pf = pFunction;
569 if (description && description[0])
571 pHook->helptext.assign(description);
574 pInfo->srvhooks.push_back(pHook);
576 /* Add to the plugin */
578 IPlugin *pPlugin = g_PluginSys.GetPluginByCtx(pFunction->GetParentContext()->GetContext());
579 if (!pPlugin->GetProperty("CommandList", (void **)&pList))
581 pList = new CmdList();
582 pPlugin->SetProperty("CommandList", pList);
586 info.type = Cmd_Server;
588 AddToPlCmdList(pList, info);
593 void AddToPlCmdList(CmdList *pList, const PlCmdInfo &info)
595 CmdList::iterator iter = pList->begin();
596 bool inserted = false;
597 const char *orig = NULL;
599 orig = info.pInfo->pCmd->GetName();
601 /* Insert this into the help list, SORTED alphabetically. */
602 while (iter != pList->end())
604 PlCmdInfo &obj = (*iter);
605 const char *cmd = obj.pInfo->pCmd->GetName();
606 if (strcmp(orig, cmd) < 0)
608 pList->insert(iter, info);
617 pList->push_back(info);
621 void ConCmdManager::AddToCmdList(ConCmdInfo *info)
623 List<ConCmdInfo *>::iterator iter = m_CmdList.begin();
625 bool inserted = false;
626 const char *orig = NULL;
628 orig = info->pCmd->GetName();
630 /* Insert this into the help list, SORTED alphabetically. */
631 while (iter != m_CmdList.end())
633 const char *cmd = NULL;
635 cmd = pInfo->pCmd->GetName();
636 if (strcmp(orig, cmd) < 0)
638 m_CmdList.insert(iter, info);
647 m_CmdList.push_back(info);
651 void ConCmdManager::UpdateAdminCmdFlags(const char *cmd, OverrideType type, FlagBits bits)
655 if (type == Override_Command)
657 if (!sm_trie_retrieve(m_pCmds, cmd, (void **)&pInfo))
662 List<CmdHook *>::iterator iter;
665 for (iter=pInfo->conhooks.begin(); iter!=pInfo->conhooks.end(); iter++)
672 pHook->pAdmin->eflags = bits;
674 pHook->pAdmin->eflags = pHook->pAdmin->flags;
676 pInfo->admin = *(pHook->pAdmin);
679 pInfo->is_admin_set = true;
680 } else if (type == Override_CommandGroup) {
682 if (!sm_trie_retrieve(m_pCmdGrps, cmd, &object))
686 int grpid = (int)object;
688 /* This is bad :( loop through all commands */
689 List<ConCmdInfo *>::iterator iter;
691 for (iter=m_CmdList.begin(); iter!=m_CmdList.end(); iter++)
694 for (List<CmdHook *>::iterator citer=pInfo->conhooks.begin();
695 citer!=pInfo->conhooks.end();
699 if (pHook->pAdmin && pHook->pAdmin->cmdGrpId == grpid)
703 pHook->pAdmin->eflags = bits;
705 pHook->pAdmin->eflags = pHook->pAdmin->flags;
707 pInfo->admin = *(pHook->pAdmin);
711 pInfo->is_admin_set = true;
715 void ConCmdManager::RemoveConCmd(ConCmdInfo *info)
717 /* Remove console-specific information
718 * This should always be true as of right now
722 /* Remove from the trie */
723 sm_trie_delete(m_pCmds, info->pCmd->GetName());
727 /* Unlink from SourceMM */
728 g_SMAPI->UnregisterConCmdBase(g_PLAPI, info->pCmd);
729 /* Delete the command's memory */
730 char *new_help = const_cast<char *>(info->pCmd->GetHelpText());
731 char *new_name = const_cast<char *>(info->pCmd->GetName());
736 /* Remove the external hook */
737 SH_REMOVE_HOOK_STATICFUNC(ConCommand, Dispatch, info->pCmd, CommandCallback, false);
741 /* Remove from list */
742 m_CmdList.remove(info);
747 bool ConCmdManager::LookForSourceModCommand(const char *cmd)
751 if (!sm_trie_retrieve(m_pCmds, cmd, (void **)&pInfo))
756 return pInfo->sourceMod && (pInfo->conhooks.size() > 0);
759 bool ConCmdManager::LookForCommandAdminFlags(const char *cmd, FlagBits *pFlags)
763 if (!sm_trie_retrieve(m_pCmds, cmd, (void **)&pInfo))
768 *pFlags = pInfo->admin.eflags;
770 return pInfo->is_admin_set;
773 ConCmdInfo *ConCmdManager::AddOrFindCommand(const char *name, const char *description, int flags)
776 if (!sm_trie_retrieve(m_pCmds, name, (void **)&pInfo))
778 pInfo = new ConCmdInfo();
779 /* Find the commandopan */
780 ConCommandBase *pBase = icvar->GetCommands();
781 ConCommand *pCmd = NULL;
784 if (strcmp(pBase->GetName(), name) == 0)
786 /* Don't want to return convar with same name */
787 if (!pBase->IsCommand())
792 pCmd = (ConCommand *)pBase;
795 pBase = const_cast<ConCommandBase *>(pBase->GetNext());
800 /* Note that we have to duplicate because the source might not be
801 * a static string, and these expect static memory.
807 char *new_name = sm_strdup(name);
808 char *new_help = sm_strdup(description);
809 pCmd = new ConCommand(new_name, CommandCallback, new_help, flags);
810 pInfo->sourceMod = true;
812 SH_ADD_HOOK_STATICFUNC(ConCommand, Dispatch, pCmd, CommandCallback, false);
816 pInfo->is_admin_set = false;
818 sm_trie_insert(m_pCmds, name, pInfo);
825 void ConCmdManager::OnRootConsoleCommand(const char *command, unsigned int argcount)
829 const char *text = engine->Cmd_Argv(2);
832 CPlugin *pPlugin = g_PluginSys.GetPluginByOrder(id);
836 g_RootMenu.ConsolePrint("[SM] Plugin index %d not found.", id);
840 const sm_plugininfo_t *plinfo = pPlugin->GetPublicInfo();
841 const char *plname = IS_STR_FILLED(plinfo->name) ? plinfo->name : pPlugin->GetFilename();
844 if (!pPlugin->GetProperty("CommandList", (void **)&pList))
846 g_RootMenu.ConsolePrint("[SM] No commands found for: %s", plname);
851 g_RootMenu.ConsolePrint("[SM] No commands found for: %s", plname);
855 CmdList::iterator iter;
856 const char *type = NULL;
859 g_RootMenu.ConsolePrint("[SM] Listing %d commands for: %s", pList->size(), plname);
860 g_RootMenu.ConsolePrint(" %-17.16s %-8.7s %s", "[Name]", "[Type]", "[Help]");
861 for (iter=pList->begin();
865 PlCmdInfo &cmd = (*iter);
866 if (cmd.type == Cmd_Server)
869 } else if (cmd.type == Cmd_Console) {
871 } else if (cmd.type == Cmd_Admin) {
874 name = cmd.pInfo->pCmd->GetName();
875 if (cmd.pHook->helptext.size())
877 help = cmd.pHook->helptext.c_str();
879 help = cmd.pInfo->pCmd->GetHelpText();
881 g_RootMenu.ConsolePrint(" %-17.16s %-12.11s %s", name, type, help);
887 g_RootMenu.ConsolePrint("[SM] Usage: sm cmds <plugin #>");
890 static int g_yam_state = 0;
891 void _YamState(int state)
895 g_RootMenu.ConsolePrint("Welcome to the SourceMod Text Adventure.");
896 g_RootMenu.ConsolePrint("Type sm_text to see the last message.");
897 g_RootMenu.ConsolePrint("Type sm_text <word> to follow a capital word.");
898 g_RootMenu.ConsolePrint("-------------------------------");
899 g_RootMenu.ConsolePrint("You are at VALVE HEADQUARTERS.");
900 g_RootMenu.ConsolePrint("To your LEFT is BAILOPAN, rearranging the letters to spell");
901 g_RootMenu.ConsolePrint("\"A HARD VEAL QUEST\". FORWARD is the entrance to the building.");
902 g_RootMenu.ConsolePrint("To your RIGHT is your last chance to flee in terror.");
903 } else if (state == 1) {
904 g_RootMenu.ConsolePrint("BAILOPAN tells you that his name his pronounced");
905 g_RootMenu.ConsolePrint("\"bye low pahn,\" not \"bay low pan.\" Do you ");
906 g_RootMenu.ConsolePrint("MOCK him, or NOD quietly?");
907 } else if (state == 2) {
908 g_RootMenu.ConsolePrint("You enter the Valve building. You hear screams coming from within.");
909 g_RootMenu.ConsolePrint("A grotesque figure lumbers up to greet you; it is Gabe Newell.");
910 g_RootMenu.ConsolePrint("\"Welcome,\" he belches, \"to my lair.\"");
911 g_RootMenu.ConsolePrint("Do you SHAKE Gaben's hand, WALK past him, or OFFER a donut?");
912 } else if (state == 3) {
913 g_RootMenu.ConsolePrint("You walk into the break room. Alfred \"Alf is from Melmac\" Reynolds and");
914 g_RootMenu.ConsolePrint("Yahn \"Yeti\" Bernier are discussing something (you overhear ");
915 g_RootMenu.ConsolePrint("the phrase \"and next Steam update, here's what we should break\").");
916 g_RootMenu.ConsolePrint("Should you DIE in a fire, REPORT a bug, REQUEST a feature, or ");
917 g_RootMenu.ConsolePrint("SPRAY them with butter?");
922 void _IntExt_CallYams()
924 const char *arg = engine->Cmd_Argv(1);
926 /* should be impossible */
927 if (!arg || arg[0] == '\0')
929 _YamState(g_yam_state);
932 if (g_yam_state == 1)
934 if (strcasecmp(arg, "mock") == 0)
936 g_RootMenu.ConsolePrint("You mock BAILOPAN's pronunciation. In a fit of rage, ");
937 g_RootMenu.ConsolePrint("he sticks an INT 3 call into your chest, rendering you broken.");
938 g_RootMenu.ConsolePrint("YOU HAVE DIED. GAME OVER.");
940 } else if (strcasecmp(arg, "nod") == 0) {
941 g_RootMenu.ConsolePrint("You nod quietly, and then slowly back away into the Valve headquarters.");
944 g_RootMenu.ConsolePrint("Commands are MOCK and NOD.");
946 } else if (g_yam_state == 3) {
947 if (strcasecmp(arg, "report") == 0)
949 g_RootMenu.ConsolePrint("You report a bug to Alfred and Yeti. Immediately, both fall asleep.");
950 g_RootMenu.ConsolePrint("You decay in the break room for two years while they sleep.");
951 g_RootMenu.ConsolePrint("YOU HAVE DIED. GAME OVER.");
953 } else if (strcasecmp(arg, "request") == 0) {
954 g_RootMenu.ConsolePrint("You request a feature to Alfred and Yeti. They both mutter something");
955 g_RootMenu.ConsolePrint("about it being implemented \"soon.\" Then, by accident, someone sends");
956 g_RootMenu.ConsolePrint("a message over \"Friends.\" The entire building catches fire.");
957 g_RootMenu.ConsolePrint("YOU HAVE DIED. GAME OVER.");
959 } else if (strcasecmp(arg, "die") == 0) {
960 g_RootMenu.ConsolePrint("For no reason, you suddenly catch fire. Alfred and Yeti find this");
961 g_RootMenu.ConsolePrint("deeply disturbing, and cover your flaming corpse with Episode 2");
962 g_RootMenu.ConsolePrint("advertisements. Coming soon, with Team Fortress 2, and Portal!");
963 g_RootMenu.ConsolePrint("YOU HAVE DIED. GAME OVER.");
965 } else if (strcasecmp(arg, "spray") == 0) {
966 g_RootMenu.ConsolePrint("You spray Alfred and Yeti with butter. Like Jack Thompson to an");
967 g_RootMenu.ConsolePrint("ambulance, Gabe Newell instantly appears and devours them both.");
968 g_RootMenu.ConsolePrint("You run away, just in time, as Gabe Newell explodes, registering ");
969 g_RootMenu.ConsolePrint("a 5.6 earthquake. Outside, world peace is achieved.");
970 g_RootMenu.ConsolePrint("YOU HAVE WON.");
973 } else if (g_yam_state == 2) {
974 if (strcasecmp(arg, "shake") == 0)
976 g_RootMenu.ConsolePrint("You shake Gaben's hand. It is a terrifying and disgusting experience.");
977 g_RootMenu.ConsolePrint("However, you survive, and continue on.");
979 } else if (strcasecmp(arg, "offer") == 0) {
980 g_RootMenu.ConsolePrint("You offer Gabe Newell one (1) donut. With a gleam in his eyes, ");
981 g_RootMenu.ConsolePrint("he picks you up and devours you whole.");
982 g_RootMenu.ConsolePrint("YOU HAVE DIED. GAME OVER.");
984 } else if (strcasecmp(arg, "walk") == 0) {
985 g_RootMenu.ConsolePrint("You walk past Gabe Newell. He can't keep up with your pace!");
988 g_RootMenu.ConsolePrint("Commands are SHAKE, OFFER, and WALK.");
990 } else if (g_yam_state == 0) {
991 if (strcasecmp(arg, "left") == 0)
994 } else if (strcasecmp(arg, "right") == 0) {
995 g_RootMenu.ConsolePrint("You run away from the Valve headquarters in sheer terror.");
996 g_RootMenu.ConsolePrint("While running, you smash into an unknown person, who turns out to be your soul mate.");
997 g_RootMenu.ConsolePrint("You marry and raise a family of 3 kids.");
998 g_RootMenu.ConsolePrint("Many years later, you look back, and realize this was your best choice.");
999 g_RootMenu.ConsolePrint("YOU HAVE WON.");
1001 } else if (strcasecmp(arg, "forward") == 0) {
1003 } else if (arg[0] != '\0') {
1004 g_RootMenu.ConsolePrint("Commands are FORWARD, LEFT, and RIGHT.");
1009 void _IntExt_EnableYams()
1011 static ConCommand *pCmd = NULL;
1014 pCmd = new ConCommand("sm_text", _IntExt_CallYams, "Fountain of Yams Adventure Game", FCVAR_GAMEDLL);
1015 g_RootMenu.ConsolePrint("Something is now enabled...");
1017 g_RootMenu.ConsolePrint("Something is already enabled...");