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()
207 * Note: Console commands will EITHER go through IServerGameDLL::ClientCommand,
208 * OR this dispatch. They will NEVER go through both.
210 * Whether or not it goes through the callback is determined by FCVAR_GAMEDLL
213 strncopy(cmd, engine->Cmd_Argv(0), sizeof(cmd));
216 if (!sm_trie_retrieve(m_pCmds, cmd, (void **)&pInfo))
221 cell_t result = Pl_Continue;
222 int args = engine->Cmd_Argc() - 1;
224 List<CmdHook *>::iterator iter;
227 /* Execute server-only commands if viable */
228 if (m_CmdClient == 0 && pInfo->srvhooks.size())
230 cell_t tempres = result;
231 for (iter=pInfo->srvhooks.begin();
232 iter!=pInfo->srvhooks.end();
236 if (!pHook->pf->IsRunnable())
240 pHook->pf->PushCell(args);
241 if (pHook->pf->Execute(&tempres) == SP_ERROR_NONE)
243 if (tempres > result)
247 if (result == Pl_Stop)
254 /* Check if there's an early stop */
255 if (result >= Pl_Stop)
257 if (!pInfo->sourceMod)
259 RETURN_META(MRES_SUPERCEDE);
265 /* Execute console commands */
266 if (pInfo->conhooks.size())
268 cell_t tempres = result;
269 for (iter=pInfo->conhooks.begin();
270 iter!=pInfo->conhooks.end();
274 if (!pHook->pf->IsRunnable())
280 && !CheckAccess(m_CmdClient, cmd, pHook->pAdmin))
282 if (result < Pl_Handled)
289 /* On a listen server, sometimes the server host's client index can be set as 0.
290 * So index 1 is passed to the command callback to correct this potential problem.
292 if (m_CmdClient == 0 && !engine->IsDedicatedServer())
294 pHook->pf->PushCell(1);
296 pHook->pf->PushCell(m_CmdClient);
299 pHook->pf->PushCell(args);
300 if (pHook->pf->Execute(&tempres) == SP_ERROR_NONE)
302 if (tempres > result)
306 if (result == Pl_Stop)
314 if (result >= Pl_Handled)
316 if (!pInfo->sourceMod)
318 RETURN_META(MRES_SUPERCEDE);
324 bool ConCmdManager::CheckCommandAccess(int client, const char *cmd, FlagBits cmdflags)
326 if (cmdflags == 0 || client == 0)
331 /* If running listen server, then client 1 is the server host and should have 'root' access */
332 if (client == 1 && !engine->IsDedicatedServer())
337 CPlayer *player = g_Players.GetPlayerByIndex(client);
339 || player->GetEdict() == NULL
340 || player->IsFakeClient())
345 AdminId adm = player->GetAdminId();
346 if (adm != INVALID_ADMIN_ID)
348 FlagBits bits = g_Admins.GetAdminFlags(adm, Access_Effective);
350 /* root knows all, WHOA */
351 if ((bits & ADMFLAG_ROOT) == ADMFLAG_ROOT)
356 /* Check for overrides
357 * :TODO: is it worth optimizing this?
359 unsigned int groups = g_Admins.GetAdminGroupCount(adm);
362 bool override = false;
363 for (unsigned int i=0; i<groups; i++)
365 gid = g_Admins.GetAdminGroup(adm, i, NULL);
366 /* First get group-level override */
367 override = g_Admins.GetGroupCommandOverride(gid, cmd, Override_CommandGroup, &rule);
368 /* Now get the specific command override */
369 if (g_Admins.GetGroupCommandOverride(gid, cmd, Override_Command, &rule))
375 if (rule == Command_Allow)
378 } else if (rule == Command_Deny) {
384 /* See if our other flags match */
385 if ((bits & cmdflags) == cmdflags)
394 bool ConCmdManager::CheckAccess(int client, const char *cmd, AdminCmdInfo *pAdmin)
396 if (CheckCommandAccess(client, cmd, pAdmin->eflags))
401 edict_t *pEdict = engine->PEntityOfEntIndex(client);
403 /* If we got here, the command failed... */
405 if (g_Translator.CoreTrans(client, buffer, sizeof(buffer), "No Access", NULL, NULL)
408 snprintf(buffer, sizeof(buffer), "You do not have access to this command");
411 unsigned int replyto = g_ChatTriggers.GetReplyTo();
412 if (replyto == SM_REPLY_CONSOLE)
414 char fullbuffer[192];
415 snprintf(fullbuffer, sizeof(fullbuffer), "[SM] %s.\n", buffer);
416 engine->ClientPrintf(pEdict, fullbuffer);
417 } else if (replyto == SM_REPLY_CHAT) {
418 char fullbuffer[192];
419 snprintf(fullbuffer, sizeof(fullbuffer), "[SM] %s.", buffer);
420 g_HL2.TextMsg(client, HUD_PRINTTALK, fullbuffer);
426 bool ConCmdManager::AddConsoleCommand(IPluginFunction *pFunction,
428 const char *description,
431 ConCmdInfo *pInfo = AddOrFindCommand(name, description, flags);
438 CmdHook *pHook = new CmdHook();
440 pHook->pf = pFunction;
441 if (description && description[0])
443 pHook->helptext.assign(description);
445 pInfo->conhooks.push_back(pHook);
447 /* Add to the plugin */
449 IPlugin *pPlugin = g_PluginSys.GetPluginByCtx(pFunction->GetParentContext()->GetContext());
450 if (!pPlugin->GetProperty("CommandList", (void **)&pList))
452 pList = new CmdList();
453 pPlugin->SetProperty("CommandList", pList);
457 info.type = Cmd_Console;
459 AddToPlCmdList(pList, info);
464 bool ConCmdManager::AddAdminCommand(IPluginFunction *pFunction,
468 const char *description,
471 ConCmdInfo *pInfo = AddOrFindCommand(name, description, flags);
478 CmdHook *pHook = new CmdHook();
479 AdminCmdInfo *pAdmin = new AdminCmdInfo();
481 pHook->pf = pFunction;
482 if (description && description[0])
484 pHook->helptext.assign(description);
486 pHook->pAdmin = pAdmin;
490 if (!sm_trie_retrieve(m_pCmdGrps, group, (void **)&object))
492 grpid = m_Strings.AddString(group);
493 sm_trie_insert(m_pCmdGrps, group, (void *)grpid);
498 pAdmin->cmdGrpId = grpid;
499 pAdmin->flags = adminflags;
501 /* First get the command group override, if any */
502 bool override = g_Admins.GetCommandOverride(group,
503 Override_CommandGroup,
506 /* Next get the command override, if any */
507 if (g_Admins.GetCommandOverride(name,
514 /* Assign normal flags if there were no overrides */
517 pAdmin->eflags = pAdmin->flags;
520 /* Finally, add the hook */
521 pInfo->conhooks.push_back(pHook);
522 pInfo->admin = *(pHook->pAdmin);
523 pInfo->is_admin_set = true;
525 /* Now add to the plugin */
527 IPlugin *pPlugin = g_PluginSys.GetPluginByCtx(pFunction->GetParentContext()->GetContext());
528 if (!pPlugin->GetProperty("CommandList", (void **)&pList))
530 pList = new CmdList();
531 pPlugin->SetProperty("CommandList", pList);
535 info.type = Cmd_Admin;
537 AddToPlCmdList(pList, info);
542 bool ConCmdManager::AddServerCommand(IPluginFunction *pFunction,
544 const char *description,
548 ConCmdInfo *pInfo = AddOrFindCommand(name, description, flags);
555 CmdHook *pHook = new CmdHook();
557 pHook->pf = pFunction;
558 if (description && description[0])
560 pHook->helptext.assign(description);
563 pInfo->srvhooks.push_back(pHook);
565 /* Add to the plugin */
567 IPlugin *pPlugin = g_PluginSys.GetPluginByCtx(pFunction->GetParentContext()->GetContext());
568 if (!pPlugin->GetProperty("CommandList", (void **)&pList))
570 pList = new CmdList();
571 pPlugin->SetProperty("CommandList", pList);
575 info.type = Cmd_Server;
577 AddToPlCmdList(pList, info);
582 void AddToPlCmdList(CmdList *pList, const PlCmdInfo &info)
584 CmdList::iterator iter = pList->begin();
585 bool inserted = false;
586 const char *orig = NULL;
588 orig = info.pInfo->pCmd->GetName();
590 /* Insert this into the help list, SORTED alphabetically. */
591 while (iter != pList->end())
593 PlCmdInfo &obj = (*iter);
594 const char *cmd = obj.pInfo->pCmd->GetName();
595 if (strcmp(orig, cmd) < 0)
597 pList->insert(iter, info);
606 pList->push_back(info);
610 void ConCmdManager::AddToCmdList(ConCmdInfo *info)
612 List<ConCmdInfo *>::iterator iter = m_CmdList.begin();
614 bool inserted = false;
615 const char *orig = NULL;
617 orig = info->pCmd->GetName();
619 /* Insert this into the help list, SORTED alphabetically. */
620 while (iter != m_CmdList.end())
622 const char *cmd = NULL;
624 cmd = pInfo->pCmd->GetName();
625 if (strcmp(orig, cmd) < 0)
627 m_CmdList.insert(iter, info);
636 m_CmdList.push_back(info);
640 void ConCmdManager::UpdateAdminCmdFlags(const char *cmd, OverrideType type, FlagBits bits)
644 if (type == Override_Command)
646 if (!sm_trie_retrieve(m_pCmds, cmd, (void **)&pInfo))
651 List<CmdHook *>::iterator iter;
654 for (iter=pInfo->conhooks.begin(); iter!=pInfo->conhooks.end(); iter++)
661 pHook->pAdmin->eflags = bits;
663 pHook->pAdmin->eflags = pHook->pAdmin->flags;
665 pInfo->admin = *(pHook->pAdmin);
668 pInfo->is_admin_set = true;
669 } else if (type == Override_CommandGroup) {
671 if (!sm_trie_retrieve(m_pCmdGrps, cmd, &object))
675 int grpid = (int)object;
677 /* This is bad :( loop through all commands */
678 List<ConCmdInfo *>::iterator iter;
680 for (iter=m_CmdList.begin(); iter!=m_CmdList.end(); iter++)
683 for (List<CmdHook *>::iterator citer=pInfo->conhooks.begin();
684 citer!=pInfo->conhooks.end();
688 if (pHook->pAdmin && pHook->pAdmin->cmdGrpId == grpid)
692 pHook->pAdmin->eflags = bits;
694 pHook->pAdmin->eflags = pHook->pAdmin->flags;
696 pInfo->admin = *(pHook->pAdmin);
700 pInfo->is_admin_set = true;
704 void ConCmdManager::RemoveConCmd(ConCmdInfo *info)
706 /* Remove console-specific information
707 * This should always be true as of right now
711 /* Remove from the trie */
712 sm_trie_delete(m_pCmds, info->pCmd->GetName());
716 /* Unlink from SourceMM */
717 g_SMAPI->UnregisterConCmdBase(g_PLAPI, info->pCmd);
718 /* Delete the command's memory */
719 char *new_help = const_cast<char *>(info->pCmd->GetHelpText());
720 char *new_name = const_cast<char *>(info->pCmd->GetName());
725 /* Remove the external hook */
726 SH_REMOVE_HOOK_STATICFUNC(ConCommand, Dispatch, info->pCmd, CommandCallback, false);
730 /* Remove from list */
731 m_CmdList.remove(info);
736 bool ConCmdManager::LookForSourceModCommand(const char *cmd)
740 if (!sm_trie_retrieve(m_pCmds, cmd, (void **)&pInfo))
745 return pInfo->sourceMod && (pInfo->conhooks.size() > 0);
748 bool ConCmdManager::LookForCommandAdminFlags(const char *cmd, FlagBits *pFlags)
752 if (!sm_trie_retrieve(m_pCmds, cmd, (void **)&pInfo))
757 *pFlags = pInfo->admin.eflags;
759 return pInfo->is_admin_set;
762 ConCmdInfo *ConCmdManager::AddOrFindCommand(const char *name, const char *description, int flags)
765 if (!sm_trie_retrieve(m_pCmds, name, (void **)&pInfo))
767 pInfo = new ConCmdInfo();
768 /* Find the commandopan */
769 ConCommandBase *pBase = icvar->GetCommands();
770 ConCommand *pCmd = NULL;
773 if (strcmp(pBase->GetName(), name) == 0)
775 /* Don't want to return convar with same name */
776 if (!pBase->IsCommand())
781 pCmd = (ConCommand *)pBase;
784 pBase = const_cast<ConCommandBase *>(pBase->GetNext());
789 /* Note that we have to duplicate because the source might not be
790 * a static string, and these expect static memory.
796 char *new_name = sm_strdup(name);
797 char *new_help = sm_strdup(description);
798 pCmd = new ConCommand(new_name, CommandCallback, new_help, flags);
799 pInfo->sourceMod = true;
801 SH_ADD_HOOK_STATICFUNC(ConCommand, Dispatch, pCmd, CommandCallback, false);
805 pInfo->is_admin_set = false;
807 sm_trie_insert(m_pCmds, name, pInfo);
814 void ConCmdManager::OnRootConsoleCommand(const char *command, unsigned int argcount)
818 const char *text = engine->Cmd_Argv(2);
821 CPlugin *pPlugin = g_PluginSys.GetPluginByOrder(id);
825 g_RootMenu.ConsolePrint("[SM] Plugin index %d not found.", id);
829 const sm_plugininfo_t *plinfo = pPlugin->GetPublicInfo();
830 const char *plname = IS_STR_FILLED(plinfo->name) ? plinfo->name : pPlugin->GetFilename();
833 if (!pPlugin->GetProperty("CommandList", (void **)&pList))
835 g_RootMenu.ConsolePrint("[SM] No commands found for: %s", plname);
840 g_RootMenu.ConsolePrint("[SM] No commands found for: %s", plname);
844 CmdList::iterator iter;
845 const char *type = NULL;
848 g_RootMenu.ConsolePrint("[SM] Listing %d commands for: %s", pList->size(), plname);
849 g_RootMenu.ConsolePrint(" %-17.16s %-8.7s %s", "[Name]", "[Type]", "[Help]");
850 for (iter=pList->begin();
854 PlCmdInfo &cmd = (*iter);
855 if (cmd.type == Cmd_Server)
858 } else if (cmd.type == Cmd_Console) {
860 } else if (cmd.type == Cmd_Admin) {
863 name = cmd.pInfo->pCmd->GetName();
864 if (cmd.pHook->helptext.size())
866 help = cmd.pHook->helptext.c_str();
868 help = cmd.pInfo->pCmd->GetHelpText();
870 g_RootMenu.ConsolePrint(" %-17.16s %-12.11s %s", name, type, help);
876 g_RootMenu.ConsolePrint("[SM] Usage: sm cmds <plugin #>");
879 static int g_yam_state = 0;
880 void _YamState(int state)
884 g_RootMenu.ConsolePrint("Welcome to the SourceMod Text Adventure.");
885 g_RootMenu.ConsolePrint("Type sm_text to see the last message.");
886 g_RootMenu.ConsolePrint("Type sm_text <word> to follow a capital word.");
887 g_RootMenu.ConsolePrint("-------------------------------");
888 g_RootMenu.ConsolePrint("You are at VALVE HEADQUARTERS.");
889 g_RootMenu.ConsolePrint("To your LEFT is BAILOPAN, rearranging the letters to spell");
890 g_RootMenu.ConsolePrint("\"A HARD VEAL QUEST\". FORWARD is the entrance to the building.");
891 g_RootMenu.ConsolePrint("To your RIGHT is your last chance to flee in terror.");
892 } else if (state == 1) {
893 g_RootMenu.ConsolePrint("BAILOPAN tells you that his name his pronounced");
894 g_RootMenu.ConsolePrint("\"bye low pahn,\" not \"bay low pan.\" Do you ");
895 g_RootMenu.ConsolePrint("MOCK him, or NOD quietly?");
896 } else if (state == 2) {
897 g_RootMenu.ConsolePrint("You enter the Valve building. You hear screams coming from within.");
898 g_RootMenu.ConsolePrint("A grotesque figure lumbers up to greet you; it is Gabe Newell.");
899 g_RootMenu.ConsolePrint("\"Welcome,\" he belches, \"to my lair.\"");
900 g_RootMenu.ConsolePrint("Do you SHAKE Gaben's hand, WALK past him, or OFFER a donut?");
901 } else if (state == 3) {
902 g_RootMenu.ConsolePrint("You walk into the break room. Alfred \"Alf is from Melmac\" Reynolds and");
903 g_RootMenu.ConsolePrint("Yahn \"Yeti\" Bernier are discussing something (you overhear ");
904 g_RootMenu.ConsolePrint("the phrase \"and next Steam update, here's what we should break\").");
905 g_RootMenu.ConsolePrint("Should you DIE in a fire, REPORT a bug, REQUEST a feature, or ");
906 g_RootMenu.ConsolePrint("SPRAY them with butter?");
911 void _IntExt_CallYams()
913 const char *arg = engine->Cmd_Argv(1);
915 /* should be impossible */
916 if (!arg || arg[0] == '\0')
918 _YamState(g_yam_state);
921 if (g_yam_state == 1)
923 if (strcasecmp(arg, "mock") == 0)
925 g_RootMenu.ConsolePrint("You mock BAILOPAN's pronunciation. In a fit of rage, ");
926 g_RootMenu.ConsolePrint("he sticks an INT 3 call into your chest, rendering you broken.");
927 g_RootMenu.ConsolePrint("YOU HAVE DIED. GAME OVER.");
929 } else if (strcasecmp(arg, "nod") == 0) {
930 g_RootMenu.ConsolePrint("You nod quietly, and then slowly back away into the Valve headquarters.");
933 g_RootMenu.ConsolePrint("Commands are MOCK and NOD.");
935 } else if (g_yam_state == 3) {
936 if (strcasecmp(arg, "report") == 0)
938 g_RootMenu.ConsolePrint("You report a bug to Alfred and Yeti. Immediately, both fall asleep.");
939 g_RootMenu.ConsolePrint("You decay in the break room for two years while they sleep.");
940 g_RootMenu.ConsolePrint("YOU HAVE DIED. GAME OVER.");
942 } else if (strcasecmp(arg, "request") == 0) {
943 g_RootMenu.ConsolePrint("You request a feature to Alfred and Yeti. They both mutter something");
944 g_RootMenu.ConsolePrint("about it being implemented \"soon.\" Then, by accident, someone sends");
945 g_RootMenu.ConsolePrint("a message over \"Friends.\" The entire building catches fire.");
946 g_RootMenu.ConsolePrint("YOU HAVE DIED. GAME OVER.");
948 } else if (strcasecmp(arg, "die") == 0) {
949 g_RootMenu.ConsolePrint("For no reason, you suddenly catch fire. Alfred and Yeti find this");
950 g_RootMenu.ConsolePrint("deeply disturbing, and cover your flaming corpse with Episode 2");
951 g_RootMenu.ConsolePrint("advertisements. Coming soon, with Team Fortress 2, and Portal!");
952 g_RootMenu.ConsolePrint("YOU HAVE DIED. GAME OVER.");
954 } else if (strcasecmp(arg, "spray") == 0) {
955 g_RootMenu.ConsolePrint("You spray Alfred and Yeti with butter. Like Jack Thompson to an");
956 g_RootMenu.ConsolePrint("ambulance, Gabe Newell instantly appears and devours them both.");
957 g_RootMenu.ConsolePrint("You run away, just in time, as Gabe Newell explodes, registering ");
958 g_RootMenu.ConsolePrint("a 5.6 earthquake. Outside, world peace is achieved.");
959 g_RootMenu.ConsolePrint("YOU HAVE WON.");
962 } else if (g_yam_state == 2) {
963 if (strcasecmp(arg, "shake") == 0)
965 g_RootMenu.ConsolePrint("You shake Gaben's hand. It is a terrifying and disgusting experience.");
966 g_RootMenu.ConsolePrint("However, you survive, and continue on.");
968 } else if (strcasecmp(arg, "offer") == 0) {
969 g_RootMenu.ConsolePrint("You offer Gabe Newell one (1) donut. With a gleam in his eyes, ");
970 g_RootMenu.ConsolePrint("he picks you up and devours you whole.");
971 g_RootMenu.ConsolePrint("YOU HAVE DIED. GAME OVER.");
973 } else if (strcasecmp(arg, "walk") == 0) {
974 g_RootMenu.ConsolePrint("You walk past Gabe Newell. He can't keep up with your pace!");
977 g_RootMenu.ConsolePrint("Commands are SHAKE, OFFER, and WALK.");
979 } else if (g_yam_state == 0) {
980 if (strcasecmp(arg, "left") == 0)
983 } else if (strcasecmp(arg, "right") == 0) {
984 g_RootMenu.ConsolePrint("You run away from the Valve headquarters in sheer terror.");
985 g_RootMenu.ConsolePrint("While running, you smash into an unknown person, who turns out to be your soul mate.");
986 g_RootMenu.ConsolePrint("You marry and raise a family of 3 kids.");
987 g_RootMenu.ConsolePrint("Many years later, you look back, and realize this was your best choice.");
988 g_RootMenu.ConsolePrint("YOU HAVE WON.");
990 } else if (strcasecmp(arg, "forward") == 0) {
992 } else if (arg[0] != '\0') {
993 g_RootMenu.ConsolePrint("Commands are FORWARD, LEFT, and RIGHT.");
998 void _IntExt_EnableYams()
1000 static ConCommand *pCmd = NULL;
1003 pCmd = new ConCommand("sm_text", _IntExt_CallYams, "Fountain of Yams Adventure Game", FCVAR_GAMEDLL);
1004 g_RootMenu.ConsolePrint("Something is now enabled...");
1006 g_RootMenu.ConsolePrint("Something is already enabled...");