extensions can now be built for multiple engines, and will autoload from auto.X.Y folders
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 #if defined ORANGEBOX_BUILD
44 SH_DECL_HOOK1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &);
46 SH_DECL_HOOK0_void(ConCommand, Dispatch, SH_NOATTRIB, false);
49 SH_DECL_HOOK1_void(IServerGameClients, SetCommandClient, SH_NOATTRIB, false, int);
57 typedef List<PlCmdInfo> CmdList;
59 void AddToPlCmdList(CmdList *pList, const PlCmdInfo &info);
61 ConCmdManager::ConCmdManager() : m_Strings(1024)
63 m_pCmds = sm_trie_create();
64 m_pCmdGrps = sm_trie_create();
68 ConCmdManager::~ConCmdManager()
70 sm_trie_destroy(m_pCmds);
71 sm_trie_destroy(m_pCmdGrps);
74 void ConCmdManager::OnSourceModAllInitialized()
76 g_PluginSys.AddPluginsListener(this);
77 g_RootMenu.AddRootConsoleCommand("cmds", "List console commands", this);
78 SH_ADD_HOOK_MEMFUNC(IServerGameClients, SetCommandClient, serverClients, this, &ConCmdManager::SetCommandClient, false);
81 void ConCmdManager::OnSourceModShutdown()
83 /* All commands should already be removed by the time we're done */
84 SH_REMOVE_HOOK_MEMFUNC(IServerGameClients, SetCommandClient, serverClients, this, &ConCmdManager::SetCommandClient, false);
85 g_RootMenu.RemoveRootConsoleCommand("cmds", this);
88 void ConCmdManager::RemoveConCmds(List<CmdHook *> &cmdlist, IPluginContext *pContext)
90 List<CmdHook *>::iterator iter = cmdlist.begin();
93 while (iter != cmdlist.end())
96 if (pHook->pf->GetParentContext() == pContext)
100 iter = cmdlist.erase(iter);
107 void ConCmdManager::OnPluginDestroyed(IPlugin *plugin)
110 List<ConCmdInfo *> removed;
111 if (plugin->GetProperty("CommandList", (void **)&pList, true))
113 IPluginContext *pContext = plugin->GetBaseContext();
114 CmdList::iterator iter;
116 * Only bother if there's an actual command list on this plugin...
118 for (iter=pList->begin();
122 PlCmdInfo &cmd = (*iter);
123 ConCmdInfo *pInfo = cmd.pInfo;
125 /* Has this chain already been fully cleaned/removed? */
126 if (removed.find(pInfo) != removed.end())
131 /* Remove any hooks from us on this command */
132 RemoveConCmds(pInfo->conhooks, pContext);
133 RemoveConCmds(pInfo->srvhooks, pContext);
135 /* See if there are still hooks */
136 if (pInfo->srvhooks.size())
140 if (pInfo->conhooks.size())
145 /* Remove the command, it should be safe now */
147 removed.push_back(pInfo);
152 #if defined ORANGEBOX_BUILD
153 void CommandCallback(const CCommand &command)
156 void CommandCallback()
161 g_HL2.PushCommandStack(&command);
163 g_ConCmds.InternalDispatch(command);
165 g_HL2.PopCommandStack();
168 void ConCmdManager::SetCommandClient(int client)
170 m_CmdClient = client + 1;
173 ResultType ConCmdManager::DispatchClientCommand(int client, const char *cmd, int args, ResultType type)
176 if (sm_trie_retrieve(m_pCmds, cmd, (void **)&pInfo))
178 cell_t result = type;
179 cell_t tempres = result;
180 List<CmdHook *>::iterator iter;
182 for (iter=pInfo->conhooks.begin();
183 iter!=pInfo->conhooks.end();
187 if (!pHook->pf->IsRunnable())
191 if (pHook->pAdmin && !CheckAccess(client, cmd, pHook->pAdmin))
193 if (result < Pl_Handled)
199 pHook->pf->PushCell(client);
200 pHook->pf->PushCell(args);
201 if (pHook->pf->Execute(&tempres) == SP_ERROR_NONE)
203 if (tempres > result)
207 if (result == Pl_Stop)
213 type = (ResultType)result;
219 void ConCmdManager::InternalDispatch(const CCommand &command)
221 int client = m_CmdClient;
225 CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
226 if (!pPlayer || !pPlayer->IsConnected())
233 * Note: Console commands will EITHER go through IServerGameDLL::ClientCommand,
234 * OR this dispatch. They will NEVER go through both.
236 * Whether or not it goes through the callback is determined by FCVAR_GAMEDLL
238 const char *cmd = g_HL2.CurrentCommandName();
241 if (!sm_trie_retrieve(m_pCmds, cmd, (void **)&pInfo))
246 cell_t result = Pl_Continue;
247 int args = command.ArgC() - 1;
249 List<CmdHook *>::iterator iter;
252 /* Execute server-only commands if viable */
253 if (client == 0 && pInfo->srvhooks.size())
255 cell_t tempres = result;
256 for (iter=pInfo->srvhooks.begin();
257 iter!=pInfo->srvhooks.end();
261 if (!pHook->pf->IsRunnable())
265 pHook->pf->PushCell(args);
266 if (pHook->pf->Execute(&tempres) == SP_ERROR_NONE)
268 if (tempres > result)
272 if (result == Pl_Stop)
279 /* Check if there's an early stop */
280 if (result >= Pl_Stop)
282 if (!pInfo->sourceMod)
284 RETURN_META(MRES_SUPERCEDE);
290 /* Execute console commands */
291 if (pInfo->conhooks.size())
293 cell_t tempres = result;
294 for (iter=pInfo->conhooks.begin();
295 iter!=pInfo->conhooks.end();
299 if (!pHook->pf->IsRunnable())
305 && !CheckAccess(client, cmd, pHook->pAdmin))
307 if (result < Pl_Handled)
314 /* On a listen server, sometimes the server host's client index can be set as 0.
315 * So index 1 is passed to the command callback to correct this potential problem.
317 if (client == 0 && !engine->IsDedicatedServer())
319 pHook->pf->PushCell(1);
321 pHook->pf->PushCell(client);
324 pHook->pf->PushCell(args);
325 if (pHook->pf->Execute(&tempres) == SP_ERROR_NONE)
327 if (tempres > result)
331 if (result == Pl_Stop)
339 if (result >= Pl_Handled)
341 if (!pInfo->sourceMod)
343 RETURN_META(MRES_SUPERCEDE);
349 bool ConCmdManager::CheckCommandAccess(int client, const char *cmd, FlagBits cmdflags)
351 if (cmdflags == 0 || client == 0)
356 /* If running listen server, then client 1 is the server host and should have 'root' access */
357 if (client == 1 && !engine->IsDedicatedServer())
362 CPlayer *player = g_Players.GetPlayerByIndex(client);
364 || player->GetEdict() == NULL
365 || player->IsFakeClient())
370 AdminId adm = player->GetAdminId();
371 if (adm != INVALID_ADMIN_ID)
373 FlagBits bits = g_Admins.GetAdminFlags(adm, Access_Effective);
375 /* root knows all, WHOA */
376 if ((bits & ADMFLAG_ROOT) == ADMFLAG_ROOT)
381 /* Check for overrides
382 * :TODO: is it worth optimizing this?
384 unsigned int groups = g_Admins.GetAdminGroupCount(adm);
387 bool override = false;
388 for (unsigned int i=0; i<groups; i++)
390 gid = g_Admins.GetAdminGroup(adm, i, NULL);
391 /* First get group-level override */
392 override = g_Admins.GetGroupCommandOverride(gid, cmd, Override_CommandGroup, &rule);
393 /* Now get the specific command override */
394 if (g_Admins.GetGroupCommandOverride(gid, cmd, Override_Command, &rule))
400 if (rule == Command_Allow)
403 } else if (rule == Command_Deny) {
409 /* See if our other flags match */
410 if ((bits & cmdflags) == cmdflags)
419 bool ConCmdManager::CheckAccess(int client, const char *cmd, AdminCmdInfo *pAdmin)
421 if (CheckCommandAccess(client, cmd, pAdmin->eflags))
426 edict_t *pEdict = engine->PEntityOfEntIndex(client);
428 /* If we got here, the command failed... */
430 if (g_Translator.CoreTrans(client, buffer, sizeof(buffer), "No Access", NULL, NULL)
433 snprintf(buffer, sizeof(buffer), "You do not have access to this command");
436 unsigned int replyto = g_ChatTriggers.GetReplyTo();
437 if (replyto == SM_REPLY_CONSOLE)
439 char fullbuffer[192];
440 snprintf(fullbuffer, sizeof(fullbuffer), "[SM] %s.\n", buffer);
441 engine->ClientPrintf(pEdict, fullbuffer);
442 } else if (replyto == SM_REPLY_CHAT) {
443 char fullbuffer[192];
444 snprintf(fullbuffer, sizeof(fullbuffer), "[SM] %s.", buffer);
445 g_HL2.TextMsg(client, HUD_PRINTTALK, fullbuffer);
451 bool ConCmdManager::AddConsoleCommand(IPluginFunction *pFunction,
453 const char *description,
456 ConCmdInfo *pInfo = AddOrFindCommand(name, description, flags);
463 CmdHook *pHook = new CmdHook();
465 pHook->pf = pFunction;
466 if (description && description[0])
468 pHook->helptext.assign(description);
470 pInfo->conhooks.push_back(pHook);
472 /* Add to the plugin */
474 IPlugin *pPlugin = g_PluginSys.GetPluginByCtx(pFunction->GetParentContext()->GetContext());
475 if (!pPlugin->GetProperty("CommandList", (void **)&pList))
477 pList = new CmdList();
478 pPlugin->SetProperty("CommandList", pList);
482 info.type = Cmd_Console;
484 AddToPlCmdList(pList, info);
489 bool ConCmdManager::AddAdminCommand(IPluginFunction *pFunction,
493 const char *description,
496 ConCmdInfo *pInfo = AddOrFindCommand(name, description, flags);
503 CmdHook *pHook = new CmdHook();
504 AdminCmdInfo *pAdmin = new AdminCmdInfo();
506 pHook->pf = pFunction;
507 if (description && description[0])
509 pHook->helptext.assign(description);
511 pHook->pAdmin = pAdmin;
515 if (!sm_trie_retrieve(m_pCmdGrps, group, (void **)&object))
517 grpid = m_Strings.AddString(group);
518 sm_trie_insert(m_pCmdGrps, group, (void *)grpid);
523 pAdmin->cmdGrpId = grpid;
524 pAdmin->flags = adminflags;
526 /* First get the command group override, if any */
527 bool override = g_Admins.GetCommandOverride(group,
528 Override_CommandGroup,
531 /* Next get the command override, if any */
532 if (g_Admins.GetCommandOverride(name,
539 /* Assign normal flags if there were no overrides */
542 pAdmin->eflags = pAdmin->flags;
545 /* Finally, add the hook */
546 pInfo->conhooks.push_back(pHook);
547 pInfo->admin = *(pHook->pAdmin);
548 pInfo->is_admin_set = true;
550 /* Now add to the plugin */
552 IPlugin *pPlugin = g_PluginSys.GetPluginByCtx(pFunction->GetParentContext()->GetContext());
553 if (!pPlugin->GetProperty("CommandList", (void **)&pList))
555 pList = new CmdList();
556 pPlugin->SetProperty("CommandList", pList);
560 info.type = Cmd_Admin;
562 AddToPlCmdList(pList, info);
567 bool ConCmdManager::AddServerCommand(IPluginFunction *pFunction,
569 const char *description,
573 ConCmdInfo *pInfo = AddOrFindCommand(name, description, flags);
580 CmdHook *pHook = new CmdHook();
582 pHook->pf = pFunction;
583 if (description && description[0])
585 pHook->helptext.assign(description);
588 pInfo->srvhooks.push_back(pHook);
590 /* Add to the plugin */
592 IPlugin *pPlugin = g_PluginSys.GetPluginByCtx(pFunction->GetParentContext()->GetContext());
593 if (!pPlugin->GetProperty("CommandList", (void **)&pList))
595 pList = new CmdList();
596 pPlugin->SetProperty("CommandList", pList);
600 info.type = Cmd_Server;
602 AddToPlCmdList(pList, info);
607 void AddToPlCmdList(CmdList *pList, const PlCmdInfo &info)
609 CmdList::iterator iter = pList->begin();
610 bool inserted = false;
611 const char *orig = NULL;
613 orig = info.pInfo->pCmd->GetName();
615 /* Insert this into the help list, SORTED alphabetically. */
616 while (iter != pList->end())
618 PlCmdInfo &obj = (*iter);
619 const char *cmd = obj.pInfo->pCmd->GetName();
620 if (strcmp(orig, cmd) < 0)
622 pList->insert(iter, info);
631 pList->push_back(info);
635 void ConCmdManager::AddToCmdList(ConCmdInfo *info)
637 List<ConCmdInfo *>::iterator iter = m_CmdList.begin();
639 bool inserted = false;
640 const char *orig = NULL;
642 orig = info->pCmd->GetName();
644 /* Insert this into the help list, SORTED alphabetically. */
645 while (iter != m_CmdList.end())
647 const char *cmd = NULL;
649 cmd = pInfo->pCmd->GetName();
650 if (strcmp(orig, cmd) < 0)
652 m_CmdList.insert(iter, info);
661 m_CmdList.push_back(info);
665 void ConCmdManager::UpdateAdminCmdFlags(const char *cmd, OverrideType type, FlagBits bits, bool remove)
669 if (type == Override_Command)
671 if (!sm_trie_retrieve(m_pCmds, cmd, (void **)&pInfo))
676 List<CmdHook *>::iterator iter;
679 for (iter=pInfo->conhooks.begin(); iter!=pInfo->conhooks.end(); iter++)
686 pHook->pAdmin->eflags = bits;
688 pHook->pAdmin->eflags = pHook->pAdmin->flags;
690 pInfo->admin = *(pHook->pAdmin);
693 pInfo->is_admin_set = true;
694 } else if (type == Override_CommandGroup) {
696 if (!sm_trie_retrieve(m_pCmdGrps, cmd, &object))
700 int grpid = (int)object;
702 /* This is bad :( loop through all commands */
703 List<ConCmdInfo *>::iterator iter;
705 for (iter=m_CmdList.begin(); iter!=m_CmdList.end(); iter++)
708 for (List<CmdHook *>::iterator citer=pInfo->conhooks.begin();
709 citer!=pInfo->conhooks.end();
713 if (pHook->pAdmin && pHook->pAdmin->cmdGrpId == grpid)
717 pHook->pAdmin->eflags = bits;
719 pHook->pAdmin->eflags = pHook->pAdmin->flags;
721 pInfo->admin = *(pHook->pAdmin);
725 pInfo->is_admin_set = true;
729 void ConCmdManager::RemoveConCmd(ConCmdInfo *info)
731 /* Remove console-specific information
732 * This should always be true as of right now
736 /* Remove from the trie */
737 sm_trie_delete(m_pCmds, info->pCmd->GetName());
741 /* Unlink from SourceMM */
742 g_SMAPI->UnregisterConCommandBase(g_PLAPI, info->pCmd);
743 /* Delete the command's memory */
744 char *new_help = const_cast<char *>(info->pCmd->GetHelpText());
745 char *new_name = const_cast<char *>(info->pCmd->GetName());
750 /* Remove the external hook */
751 SH_REMOVE_HOOK_STATICFUNC(ConCommand, Dispatch, info->pCmd, CommandCallback, false);
755 /* Remove from list */
756 m_CmdList.remove(info);
761 bool ConCmdManager::LookForSourceModCommand(const char *cmd)
765 if (!sm_trie_retrieve(m_pCmds, cmd, (void **)&pInfo))
770 return pInfo->sourceMod && (pInfo->conhooks.size() > 0);
773 bool ConCmdManager::LookForCommandAdminFlags(const char *cmd, FlagBits *pFlags)
777 if (!sm_trie_retrieve(m_pCmds, cmd, (void **)&pInfo))
782 *pFlags = pInfo->admin.eflags;
784 return pInfo->is_admin_set;
787 ConCmdInfo *ConCmdManager::AddOrFindCommand(const char *name, const char *description, int flags)
790 if (!sm_trie_retrieve(m_pCmds, name, (void **)&pInfo))
792 pInfo = new ConCmdInfo();
793 /* Find the commandopan */
794 ConCommandBase *pBase = icvar->GetCommands();
795 ConCommand *pCmd = NULL;
798 if (strcmp(pBase->GetName(), name) == 0)
800 /* Don't want to return convar with same name */
801 if (!pBase->IsCommand())
806 pCmd = (ConCommand *)pBase;
809 pBase = const_cast<ConCommandBase *>(pBase->GetNext());
814 /* Note that we have to duplicate because the source might not be
815 * a static string, and these expect static memory.
821 char *new_name = sm_strdup(name);
822 char *new_help = sm_strdup(description);
823 pCmd = new ConCommand(new_name, CommandCallback, new_help, flags);
824 pInfo->sourceMod = true;
826 SH_ADD_HOOK_STATICFUNC(ConCommand, Dispatch, pCmd, CommandCallback, false);
830 pInfo->is_admin_set = false;
832 sm_trie_insert(m_pCmds, name, pInfo);
839 void ConCmdManager::OnRootConsoleCommand(const char *cmdname, const CCommand &command)
841 if (command.ArgC() >= 3)
843 const char *text = command.Arg(2);
846 CPlugin *pPlugin = g_PluginSys.GetPluginByOrder(id);
850 g_RootMenu.ConsolePrint("[SM] Plugin index %d not found.", id);
854 const sm_plugininfo_t *plinfo = pPlugin->GetPublicInfo();
855 const char *plname = IS_STR_FILLED(plinfo->name) ? plinfo->name : pPlugin->GetFilename();
858 if (!pPlugin->GetProperty("CommandList", (void **)&pList))
860 g_RootMenu.ConsolePrint("[SM] No commands found for: %s", plname);
865 g_RootMenu.ConsolePrint("[SM] No commands found for: %s", plname);
869 CmdList::iterator iter;
870 const char *type = NULL;
873 g_RootMenu.ConsolePrint("[SM] Listing %d commands for: %s", pList->size(), plname);
874 g_RootMenu.ConsolePrint(" %-17.16s %-8.7s %s", "[Name]", "[Type]", "[Help]");
875 for (iter=pList->begin();
879 PlCmdInfo &cmd = (*iter);
880 if (cmd.type == Cmd_Server)
883 } else if (cmd.type == Cmd_Console) {
885 } else if (cmd.type == Cmd_Admin) {
888 name = cmd.pInfo->pCmd->GetName();
889 if (cmd.pHook->helptext.size())
891 help = cmd.pHook->helptext.c_str();
893 help = cmd.pInfo->pCmd->GetHelpText();
895 g_RootMenu.ConsolePrint(" %-17.16s %-12.11s %s", name, type, help);
901 g_RootMenu.ConsolePrint("[SM] Usage: sm cmds <plugin #>");
904 static int g_yam_state = 0;
905 void _YamState(int state)
909 g_RootMenu.ConsolePrint("Welcome to the SourceMod Text Adventure.");
910 g_RootMenu.ConsolePrint("Type sm_text to see the last message.");
911 g_RootMenu.ConsolePrint("Type sm_text <word> to follow a capital word.");
912 g_RootMenu.ConsolePrint("-------------------------------");
913 g_RootMenu.ConsolePrint("You are at VALVE HEADQUARTERS.");
914 g_RootMenu.ConsolePrint("To your LEFT is BAILOPAN, rearranging the letters to spell");
915 g_RootMenu.ConsolePrint("\"A HARD VEAL QUEST\". FORWARD is the entrance to the building.");
916 g_RootMenu.ConsolePrint("To your RIGHT is your last chance to flee in terror.");
917 } else if (state == 1) {
918 g_RootMenu.ConsolePrint("BAILOPAN tells you that his name his pronounced");
919 g_RootMenu.ConsolePrint("\"bye low pahn,\" not \"bay low pan.\" Do you ");
920 g_RootMenu.ConsolePrint("MOCK him, or NOD quietly?");
921 } else if (state == 2) {
922 g_RootMenu.ConsolePrint("You enter the Valve building. You hear screams coming from within.");
923 g_RootMenu.ConsolePrint("A grotesque figure lumbers up to greet you; it is Gabe Newell.");
924 g_RootMenu.ConsolePrint("\"Welcome,\" he belches, \"to my lair.\"");
925 g_RootMenu.ConsolePrint("Do you SHAKE Gaben's hand, WALK past him, or OFFER a donut?");
926 } else if (state == 3) {
927 g_RootMenu.ConsolePrint("You walk into the break room. Alfred \"Alf is from Melmac\" Reynolds and");
928 g_RootMenu.ConsolePrint("Yahn \"Yeti\" Bernier are discussing something (you overhear ");
929 g_RootMenu.ConsolePrint("the phrase \"and next Steam update, here's what we should break\").");
930 g_RootMenu.ConsolePrint("Should you DIE in a fire, REPORT a bug, REQUEST a feature, or ");
931 g_RootMenu.ConsolePrint("SPRAY them with butter?");
936 #if defined ORANGEBOX_BUILD
937 void _IntExt_CallYams(const CCommand &cmd)
940 void _IntExt_CallYams()
944 const char *arg = cmd.Arg(1);
946 /* should be impossible */
947 if (!arg || arg[0] == '\0')
949 _YamState(g_yam_state);
952 if (g_yam_state == 1)
954 if (strcasecmp(arg, "mock") == 0)
956 g_RootMenu.ConsolePrint("You mock BAILOPAN's pronunciation. In a fit of rage, ");
957 g_RootMenu.ConsolePrint("he sticks an INT 3 call into your chest, rendering you broken.");
958 g_RootMenu.ConsolePrint("YOU HAVE DIED. GAME OVER.");
960 } else if (strcasecmp(arg, "nod") == 0) {
961 g_RootMenu.ConsolePrint("You nod quietly, and then slowly back away into the Valve headquarters.");
964 g_RootMenu.ConsolePrint("Commands are MOCK and NOD.");
966 } else if (g_yam_state == 3) {
967 if (strcasecmp(arg, "report") == 0)
969 g_RootMenu.ConsolePrint("You report a bug to Alfred and Yeti. Immediately, both fall asleep.");
970 g_RootMenu.ConsolePrint("You decay in the break room for two years while they sleep.");
971 g_RootMenu.ConsolePrint("YOU HAVE DIED. GAME OVER.");
973 } else if (strcasecmp(arg, "request") == 0) {
974 g_RootMenu.ConsolePrint("You request a feature to Alfred and Yeti. They both mutter something");
975 g_RootMenu.ConsolePrint("about it being implemented \"soon.\" Then, by accident, someone sends");
976 g_RootMenu.ConsolePrint("a message over \"Friends.\" The entire building catches fire.");
977 g_RootMenu.ConsolePrint("YOU HAVE DIED. GAME OVER.");
979 } else if (strcasecmp(arg, "die") == 0) {
980 g_RootMenu.ConsolePrint("For no reason, you suddenly catch fire. Alfred and Yeti find this");
981 g_RootMenu.ConsolePrint("deeply disturbing, and cover your flaming corpse with Episode 2");
982 g_RootMenu.ConsolePrint("advertisements. Coming soon, with Team Fortress 2, and Portal!");
983 g_RootMenu.ConsolePrint("YOU HAVE DIED. GAME OVER.");
985 } else if (strcasecmp(arg, "spray") == 0) {
986 g_RootMenu.ConsolePrint("You spray Alfred and Yeti with butter. Like Jack Thompson to an");
987 g_RootMenu.ConsolePrint("ambulance, Gabe Newell instantly appears and devours them both.");
988 g_RootMenu.ConsolePrint("You run away, just in time, as Gabe Newell explodes, registering ");
989 g_RootMenu.ConsolePrint("a 5.6 earthquake. Outside, world peace is achieved.");
990 g_RootMenu.ConsolePrint("YOU HAVE WON.");
993 } else if (g_yam_state == 2) {
994 if (strcasecmp(arg, "shake") == 0)
996 g_RootMenu.ConsolePrint("You shake Gaben's hand. It is a terrifying and disgusting experience.");
997 g_RootMenu.ConsolePrint("However, you survive, and continue on.");
999 } else if (strcasecmp(arg, "offer") == 0) {
1000 g_RootMenu.ConsolePrint("You offer Gabe Newell one (1) donut. With a gleam in his eyes, ");
1001 g_RootMenu.ConsolePrint("he picks you up and devours you whole.");
1002 g_RootMenu.ConsolePrint("YOU HAVE DIED. GAME OVER.");
1004 } else if (strcasecmp(arg, "walk") == 0) {
1005 g_RootMenu.ConsolePrint("You walk past Gabe Newell. He can't keep up with your pace!");
1008 g_RootMenu.ConsolePrint("Commands are SHAKE, OFFER, and WALK.");
1010 } else if (g_yam_state == 0) {
1011 if (strcasecmp(arg, "left") == 0)
1014 } else if (strcasecmp(arg, "right") == 0) {
1015 g_RootMenu.ConsolePrint("You run away from the Valve headquarters in sheer terror.");
1016 g_RootMenu.ConsolePrint("While running, you smash into an unknown person, who turns out to be your soul mate.");
1017 g_RootMenu.ConsolePrint("You marry and raise a family of 3 kids.");
1018 g_RootMenu.ConsolePrint("Many years later, you look back, and realize this was your best choice.");
1019 g_RootMenu.ConsolePrint("YOU HAVE WON.");
1021 } else if (strcasecmp(arg, "forward") == 0) {
1023 } else if (arg[0] != '\0') {
1024 g_RootMenu.ConsolePrint("Commands are FORWARD, LEFT, and RIGHT.");
1029 void _IntExt_EnableYams()
1031 static ConCommand *pCmd = NULL;
1034 pCmd = new ConCommand("sm_text", _IntExt_CallYams, "Fountain of Yams Adventure Game", FCVAR_GAMEDLL);
1035 g_RootMenu.ConsolePrint("Something is now enabled...");
1037 g_RootMenu.ConsolePrint("Something is already enabled...");