1 /* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 *
21 */
22
23 /*
24 * This file is based on WME Lite.
25 * http://dead-code.org/redir.php?target=wmelite
26 * Copyright (c) 2011 Jan Nedoma
27 */
28
29 #include "engines/wintermute/base/base_game.h"
30 #include "engines/wintermute/base/base_scriptable.h"
31 #include "engines/wintermute/base/scriptables/script.h"
32 #include "engines/wintermute/base/scriptables/script_value.h"
33 #include "engines/wintermute/base/scriptables/script_stack.h"
34
35 namespace Wintermute {
36
EmulateDLLTestExternalCalls(BaseGame * inGame,ScStack * stack,ScStack * thisStack,ScScript::TExternalFunction * function)37 bool EmulateDLLTestExternalCalls(BaseGame *inGame, ScStack *stack, ScStack *thisStack, ScScript::TExternalFunction *function) {
38 //////////////////////////////////////////////////////////////////////////
39 // IRC_init
40 // Used to connect to debug IRC server at games by Corbomite Games
41 // Specification: external "dlltest.dll" cdecl long IRC_init(string)
42 // Known usage: IRC_init(<PlayerName>)
43 // Known actions:
44 // 1. Connect to irc.starchat.net
45 // 2. Send "NICK ZU_<PlayerName>/"
46 // 3. Send "USER Blah ZbengHost ZbengServer ZbengRealname"
47 // 4. Send "Join #Zbeng"
48 // Returns 0 on success, other value on error
49 //////////////////////////////////////////////////////////////////////////
50 if (strcmp(function->name, "IRC_init") == 0) {
51 stack->correctParams(1);
52 /*const char *name =*/ stack->pop()->getString();
53
54 // do nothing
55
56 stack->pushInt(0);
57 return STATUS_OK;
58 }
59
60 //////////////////////////////////////////////////////////////////////////
61 // ChangeNick
62 // Used to update nick at debug IRC server at games by Corbomite Games
63 // Specification: external "dlltest.dll" cdecl long ChangeNick(string)
64 // Known usage: ChangeNick(<PlayerName>)
65 // Return value is never used
66 //////////////////////////////////////////////////////////////////////////
67 else if (strcmp(function->name, "ChangeNick") == 0) {
68 stack->correctParams(1);
69 /*const char *name =*/ stack->pop()->getString();
70
71 // do nothing
72
73 stack->pushInt(0);
74 return STATUS_OK;
75 }
76
77 //////////////////////////////////////////////////////////////////////////
78 // IRC_SendString
79 // Used to send debug and chat lines to an IRC server at games by Corbomite Games
80 // Specification: external "dlltest.dll" cdecl IRC_SendString(string, string)
81 // Known usage: IRC_SendString(<Message>, <Channel>)
82 // Known Channel values are: "#Zbeng" and "#ZbengDebug"
83 //////////////////////////////////////////////////////////////////////////
84 else if (strcmp(function->name, "IRC_SendString") == 0) {
85 stack->correctParams(2);
86 const char *message = stack->pop()->getString();
87 const char *channel = stack->pop()->getString();
88
89 inGame->LOG(0, "IRC logging: [%s] %s", channel, message);
90
91 stack->pushNULL();
92 return STATUS_OK;
93 }
94
95 //////////////////////////////////////////////////////////////////////////
96 // IRC_GetChatStrings
97 // Used to get chat lines from an IRC server at games by Corbomite Games
98 // Specification: external "dlltest.dll" cdecl IRC_GetChatStrings(string, long)
99 // Known usage: IRC_GetChatStrings(<Buffer>, 65535)
100 //////////////////////////////////////////////////////////////////////////
101 else if (strcmp(function->name, "IRC_GetChatStrings") == 0) {
102 stack->correctParams(2);
103 /*const char *buffer =*/ stack->pop()->getString();
104 /*int bufferMaxSize =*/ stack->pop()->getInt();
105
106 // do nothing
107
108 stack->pushNULL();
109 return STATUS_OK;
110 }
111
112 //////////////////////////////////////////////////////////////////////////
113 // IRC_quit
114 // Used to disconnect from debug IRC server at games by Corbomite Games
115 // Specification: external "dlltest.dll" cdecl IRC_quit()
116 // Known usage: IRC_quit()
117 //////////////////////////////////////////////////////////////////////////
118 else if (strcmp(function->name, "IRC_quit") == 0) {
119 stack->correctParams(0);
120
121 // do nothing
122
123 stack->pushNULL();
124 return STATUS_OK;
125 }
126
127 return STATUS_FAILED;
128 }
129
130 } // End of namespace Wintermute
131