~ubuntu-branches/ubuntu/natty/spring/natty

« back to all changes in this revision

Viewing changes to .pc/0006-fix-spelling-error.patch/rts/Lua/LuaLobby.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Scott Ritchie
  • Date: 2010-09-23 18:56:03 UTC
  • mfrom: (3.1.9 experimental)
  • Revision ID: james.westby@ubuntu.com-20100923185603-st97s5chplo42y7w
Tags: 0.82.5.1+dfsg1-1ubuntu1
* Latest upstream version for online play
* debian/control: Replace (rather than conflict) spring-engine
  - spring-engine will be a dummy package (LP: #612905)
  - also set maintainer to MOTU

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
 
2
 
 
3
#ifdef _MSC_VER
 
4
#include "StdAfx.h"
 
5
#endif
 
6
#include "LuaLobby.h"
 
7
#ifndef _MSC_VER
 
8
#include "StdAfx.h"
 
9
#endif
 
10
 
 
11
#include "Game/UI/LuaUI.h"
 
12
#include "LuaCallInCheck.h"
 
13
#include "LuaHandle.h"
 
14
#include "LuaHashString.h"
 
15
#include "LuaUtils.h"
 
16
 
 
17
 
 
18
#define REGISTER_LUA_CFUNC(x) \
 
19
        lua_pushstring(L, #x);      \
 
20
        lua_pushcfunction(L, x);    \
 
21
        lua_rawset(L, -3)
 
22
 
 
23
 
 
24
inline LuaLobby* toLuaLobby(lua_State* L, int idx)
 
25
{
 
26
        LuaLobby** lob = (LuaLobby**)luaL_checkudata(L, idx, "LuaLobby");
 
27
        if (*lob == NULL) {
 
28
                luaL_error(L, "Attempt to use a deleted LuaLobby object!");
 
29
        }
 
30
        return *lob;
 
31
}
 
32
 
 
33
 
 
34
/******************************************************************************/
 
35
/******************************************************************************/
 
36
 
 
37
LuaLobby::LuaLobby(lua_State* _L) : L(_L)
 
38
{
 
39
        if (L != luaUI->L) {
 
40
                luaL_error(L, "Tried to create a LuaLobby object in a non-LuaUI enviroment!");
 
41
        }
 
42
}
 
43
 
 
44
LuaLobby::~LuaLobby()
 
45
{
 
46
}
 
47
 
 
48
/******************************************************************************/
 
49
/******************************************************************************/
 
50
 
 
51
bool LuaLobby::PushEntries(lua_State* L)
 
52
{
 
53
        CreateMetatable(L);
 
54
 
 
55
        REGISTER_LUA_CFUNC(CreateLobby);
 
56
 
 
57
        return true;
 
58
}
 
59
 
 
60
bool LuaLobby::CreateMetatable(lua_State* L)
 
61
{
 
62
        luaL_newmetatable(L, "LuaLobby");
 
63
        HSTR_PUSH_CFUNC(L, "__gc",        meta_gc);
 
64
        HSTR_PUSH_CFUNC(L, "__index",     meta_index);
 
65
        HSTR_PUSH_CFUNC(L, "__newindex",     meta_newindex);
 
66
        LuaPushNamedString(L, "__metatable", "protected metatable");
 
67
 
 
68
        REGISTER_LUA_CFUNC(Poll);
 
69
        REGISTER_LUA_CFUNC(Connect);
 
70
        REGISTER_LUA_CFUNC(Disconnect);
 
71
        REGISTER_LUA_CFUNC(Register);
 
72
        REGISTER_LUA_CFUNC(Login);
 
73
        REGISTER_LUA_CFUNC(ConfirmAggreement);
 
74
        REGISTER_LUA_CFUNC(Rename);
 
75
        REGISTER_LUA_CFUNC(ChangePass);
 
76
        REGISTER_LUA_CFUNC(StatusUpdate);
 
77
        REGISTER_LUA_CFUNC(Channels);
 
78
        REGISTER_LUA_CFUNC(RequestMutelist);
 
79
        REGISTER_LUA_CFUNC(JoinChannel);
 
80
        REGISTER_LUA_CFUNC(LeaveChannel);
 
81
        REGISTER_LUA_CFUNC(KickChannelMember);
 
82
        REGISTER_LUA_CFUNC(ChangeTopic);
 
83
        REGISTER_LUA_CFUNC(Say);
 
84
        REGISTER_LUA_CFUNC(SayEx);
 
85
        REGISTER_LUA_CFUNC(SayPrivate);
 
86
 
 
87
        lua_pop(L, 1);
 
88
        return true;
 
89
}
 
90
 
 
91
/******************************************************************************/
 
92
/******************************************************************************/
 
93
 
 
94
int LuaLobby::CreateLobby(lua_State* L)
 
95
{
 
96
        LuaLobby* lob = new LuaLobby(L);
 
97
 
 
98
        LuaLobby** lobPtr = (LuaLobby**)lua_newuserdata(L, sizeof(LuaLobby*));
 
99
        *lobPtr = lob;
 
100
 
 
101
        luaL_getmetatable(L, "LuaLobby");
 
102
        lua_setmetatable(L, -2);
 
103
 
 
104
        lua_newtable(L);
 
105
        lob->luaRefEvents = luaL_ref(L, LUA_REGISTRYINDEX);
 
106
        if (lob->luaRefEvents == LUA_NOREF) {
 
107
                lua_pop(L, 1);
 
108
                *lobPtr = NULL;
 
109
                delete lob;
 
110
                return 0;
 
111
        }
 
112
 
 
113
        lua_pushvalue(L, 1);
 
114
        lob->luaRef = luaL_ref(L, LUA_REGISTRYINDEX);
 
115
        if (lob->luaRef == LUA_NOREF) {
 
116
                lua_pop(L, 1);
 
117
                *lobPtr = NULL;
 
118
                delete lob;
 
119
                return 0;
 
120
        }
 
121
 
 
122
        return 1;
 
123
}
 
124
 
 
125
/******************************************************************************/
 
126
/******************************************************************************/
 
127
 
 
128
int LuaLobby::meta_gc(lua_State* L)
 
129
{
 
130
        //FIXME: this might never get called because we hold a link to the userdata object in LUA_REGISTRYINDEX
 
131
 
 
132
        LuaLobby* lob = toLuaLobby(L, 1);
 
133
 
 
134
        luaL_unref(L, LUA_REGISTRYINDEX, lob->luaRef);
 
135
        luaL_unref(L, LUA_REGISTRYINDEX, lob->luaRefEvents);
 
136
 
 
137
        delete lob;
 
138
        return 0;
 
139
}
 
140
 
 
141
int LuaLobby::meta_index(lua_State* L)
 
142
{
 
143
        //! check if there is a function
 
144
        luaL_getmetatable(L, "LuaLobby");
 
145
        lua_pushvalue(L, 2);
 
146
        lua_rawget(L, -2);
 
147
        if (!lua_isnil(L, -1)) {
 
148
                return 1;
 
149
        }
 
150
        lua_pop(L, 1);
 
151
 
 
152
        LuaLobby* lob = toLuaLobby(L, 1);
 
153
        lua_rawgeti(L, LUA_REGISTRYINDEX, lob->luaRefEvents);
 
154
        lua_pushvalue(L, 2);
 
155
        lua_rawget(L, -2);
 
156
        if (!lua_isnil(L, -1)) {
 
157
                return 1;
 
158
        }
 
159
        lua_pop(L, 1);
 
160
 
 
161
        return 0;
 
162
}
 
163
 
 
164
int LuaLobby::meta_newindex(lua_State* L)
 
165
{
 
166
        //if (!lua_isfunction(L, 3)) {
 
167
        //      luaL_error(L, "tried to set non-function!");
 
168
        //}
 
169
 
 
170
        LuaLobby* lob = toLuaLobby(L, 1);
 
171
        lua_rawgeti(L, LUA_REGISTRYINDEX, lob->luaRefEvents);
 
172
        lua_pushvalue(L, 2); // name
 
173
        lua_pushvalue(L, 3); // function
 
174
        lua_rawset(L, -3);
 
175
 
 
176
        return 0;
 
177
}
 
178
 
 
179
/******************************************************************************/
 
180
/******************************************************************************/
 
181
 
 
182
inline bool LuaLobby::PushCallIn(const LuaHashString& name)
 
183
{
 
184
        // get callin lua function
 
185
        lua_rawgeti(L, LUA_REGISTRYINDEX, luaRefEvents);
 
186
        name.Push(L);
 
187
        lua_rawget(L, -2);
 
188
 
 
189
        // check if the function is valid/set
 
190
        if (lua_isfunction(L, -1)) {
 
191
                return true;
 
192
        }
 
193
        lua_pop(L, 1);
 
194
        return false;
 
195
}
 
196
 
 
197
/******************************************************************************/
 
198
/******************************************************************************/
 
199
 
 
200
int LuaLobby::Poll(lua_State *L)
 
201
{
 
202
        LuaLobby* lob = toLuaLobby(L, 1);
 
203
        lob->Poll();
 
204
        return 0;
 
205
}
 
206
 
 
207
int LuaLobby::Connect(lua_State *L)
 
208
{
 
209
        LuaLobby* lob = toLuaLobby(L, 1);
 
210
        std::string host(luaL_checkstring(L, 2));
 
211
        int port = luaL_checknumber(L, 3);
 
212
        lob->Connect(host, port);
 
213
        return 0;
 
214
}
 
215
 
 
216
int LuaLobby::Disconnect(lua_State *L)
 
217
{
 
218
        LuaLobby* lob = toLuaLobby(L, 1);
 
219
        lob->Disconnect();
 
220
        return 0;
 
221
}
 
222
 
 
223
int LuaLobby::Register(lua_State *L)
 
224
{
 
225
        LuaLobby* lob = toLuaLobby(L, 1);
 
226
        std::string user(luaL_checkstring(L, 2));
 
227
        std::string pass(luaL_checkstring(L, 3));
 
228
        lob->Register(user, pass);
 
229
        return 0;
 
230
}
 
231
 
 
232
int LuaLobby::Login(lua_State *L)
 
233
{
 
234
        LuaLobby* lob = toLuaLobby(L, 1);
 
235
        std::string user(luaL_checkstring(L, 2));
 
236
        std::string pass(luaL_checkstring(L, 3));
 
237
        lob->Login(user, pass);
 
238
        return 0;
 
239
}
 
240
 
 
241
int LuaLobby::ConfirmAggreement(lua_State *L)
 
242
{
 
243
        LuaLobby* lob = toLuaLobby(L, 1);
 
244
        lob->ConfirmAggreement();
 
245
        return 0;
 
246
}
 
247
 
 
248
int LuaLobby::Rename(lua_State *L)
 
249
{
 
250
        LuaLobby* lob = toLuaLobby(L, 1);
 
251
        std::string newname(luaL_checkstring(L, 2));
 
252
        lob->Rename(newname);
 
253
        return 0;
 
254
}
 
255
 
 
256
int LuaLobby::ChangePass(lua_State *L)
 
257
{
 
258
        LuaLobby* lob = toLuaLobby(L, 1);
 
259
        std::string oldpass(luaL_checkstring(L, 2));
 
260
        std::string newpass(luaL_checkstring(L, 3));
 
261
        lob->ChangePass(oldpass, newpass);
 
262
        return 0;
 
263
}
 
264
 
 
265
int LuaLobby::StatusUpdate(lua_State *L)
 
266
{
 
267
        LuaLobby* lob = toLuaLobby(L, 1);
 
268
        bool ingame = lua_toboolean(L, 2);
 
269
        bool away = lua_toboolean(L, 3);
 
270
        lob->StatusUpdate(ingame, away);
 
271
        return 0;
 
272
}
 
273
 
 
274
int LuaLobby::Channels(lua_State *L)
 
275
{
 
276
        LuaLobby* lob = toLuaLobby(L, 1);
 
277
        lob->Channels();
 
278
        return 0;
 
279
}
 
280
 
 
281
int LuaLobby::RequestMutelist(lua_State *L)
 
282
{
 
283
        LuaLobby* lob = toLuaLobby(L, 1);
 
284
        std::string channame(luaL_checkstring(L, 2));
 
285
        lob->RequestMutelist(channame);
 
286
        return 0;
 
287
}
 
288
 
 
289
int LuaLobby::JoinChannel(lua_State *L)
 
290
{
 
291
        LuaLobby* lob = toLuaLobby(L, 1);
 
292
        std::string channame(luaL_checkstring(L, 2));
 
293
        std::string passwd = "";
 
294
        if (lua_isstring(L, 3))
 
295
                passwd = luaL_checkstring(L, 3);
 
296
        lob->JoinChannel(channame, passwd);
 
297
        return 0;
 
298
}
 
299
 
 
300
int LuaLobby::LeaveChannel(lua_State *L)
 
301
{
 
302
        LuaLobby* lob = toLuaLobby(L, 1);
 
303
        std::string channame(luaL_checkstring(L, 2));
 
304
        lob->LeaveChannel(channame);
 
305
        return 0;
 
306
}
 
307
 
 
308
int LuaLobby::ChangeTopic(lua_State *L)
 
309
{
 
310
        LuaLobby* lob = toLuaLobby(L, 1);
 
311
        std::string channame(luaL_checkstring(L, 2));
 
312
        std::string topic(luaL_checkstring(L, 3));
 
313
        lob->ChangeTopic(channame, topic);
 
314
        return 0;
 
315
}
 
316
 
 
317
int LuaLobby::Say(lua_State *L)
 
318
{
 
319
        LuaLobby* lob = toLuaLobby(L, 1);
 
320
        std::string channame(luaL_checkstring(L, 2));
 
321
        std::string message(luaL_checkstring(L, 3));
 
322
        lob->Say(channame, message);
 
323
        return 0;
 
324
}
 
325
 
 
326
int LuaLobby::SayEx(lua_State *L)
 
327
{
 
328
        LuaLobby* lob = toLuaLobby(L, 1);
 
329
        std::string channame(luaL_checkstring(L, 2));
 
330
        std::string message(luaL_checkstring(L, 3));
 
331
        lob->SayEx(channame, message);
 
332
        return 0;
 
333
}
 
334
 
 
335
int LuaLobby::SayPrivate(lua_State *L)
 
336
{
 
337
        LuaLobby* lob = toLuaLobby(L, 1);
 
338
        std::string username(luaL_checkstring(L, 2));
 
339
        std::string message(luaL_checkstring(L, 3));
 
340
        lob->SayPrivate(username, message);
 
341
        return 0;
 
342
}
 
343
 
 
344
int LuaLobby::KickChannelMember(lua_State *L)
 
345
{
 
346
        LuaLobby* lob = toLuaLobby(L, 1);
 
347
        std::string channame(luaL_checkstring(L, 2));
 
348
        std::string user(luaL_checkstring(L, 3));
 
349
        std::string reason(luaL_checkstring(L, 4));
 
350
        lob->KickChannelMember(channame, user, reason);
 
351
        return 0;
 
352
}
 
353
 
 
354
/******************************************************************************/
 
355
/******************************************************************************/
 
356
 
 
357
void LuaLobby::DoneConnecting(bool succes, const std::string& err)
 
358
{
 
359
        LUA_CALL_IN_CHECK(L);
 
360
        lua_checkstack(L, 4);
 
361
        static const LuaHashString cmdStr(__FUNCTION__);
 
362
        if (!PushCallIn(cmdStr)) {
 
363
                return;
 
364
        }
 
365
 
 
366
        lua_pushboolean(L, succes);
 
367
        lua_pushstring(L, err.c_str());
 
368
 
 
369
        // call the routine
 
370
        luaUI->RunCallInUnsynced(cmdStr, 2, 0);
 
371
}
 
372
 
 
373
void LuaLobby::ServerGreeting(const std::string& serverVer, const std::string& springVer, int udpport, int mode)
 
374
{
 
375
        LUA_CALL_IN_CHECK(L);
 
376
        lua_checkstack(L, 6);
 
377
        static const LuaHashString cmdStr(__FUNCTION__);
 
378
        if (!PushCallIn(cmdStr)) {
 
379
                return;
 
380
        }
 
381
 
 
382
        lua_pushstring(L, serverVer.c_str());
 
383
        lua_pushstring(L, springVer.c_str());
 
384
        lua_pushnumber(L, udpport);
 
385
        lua_pushnumber(L, mode);
 
386
 
 
387
        // call the routine
 
388
        luaUI->RunCallInUnsynced(cmdStr, 4, 0);
 
389
}
 
390
 
 
391
void LuaLobby::RegisterDenied(const std::string& reason)
 
392
{
 
393
        LUA_CALL_IN_CHECK(L);
 
394
        lua_checkstack(L, 3);
 
395
        static const LuaHashString cmdStr(__FUNCTION__);
 
396
        if (!PushCallIn(cmdStr)) {
 
397
                return;
 
398
        }
 
399
 
 
400
        lua_pushstring(L, reason.c_str());
 
401
 
 
402
        // call the routine
 
403
        luaUI->RunCallInUnsynced(cmdStr, 1, 0);
 
404
}
 
405
 
 
406
void LuaLobby::RegisterAccepted()
 
407
{
 
408
        LUA_CALL_IN_CHECK(L);
 
409
        lua_checkstack(L, 2);
 
410
        static const LuaHashString cmdStr(__FUNCTION__);
 
411
        if (!PushCallIn(cmdStr)) {
 
412
                return;
 
413
        }
 
414
 
 
415
        // call the routine
 
416
        luaUI->RunCallInUnsynced(cmdStr, 0, 0);
 
417
}
 
418
 
 
419
void LuaLobby::LoginDenied(const std::string& reason)
 
420
{
 
421
        LUA_CALL_IN_CHECK(L);
 
422
        lua_checkstack(L, 3);
 
423
        static const LuaHashString cmdStr(__FUNCTION__);
 
424
        if (!PushCallIn(cmdStr)) {
 
425
                return;
 
426
        }
 
427
 
 
428
        lua_pushstring(L, reason.c_str());
 
429
 
 
430
        // call the routine
 
431
        luaUI->RunCallInUnsynced(cmdStr, 1, 0);
 
432
}
 
433
 
 
434
void LuaLobby::LoginEnd()
 
435
{
 
436
        LUA_CALL_IN_CHECK(L);
 
437
        lua_checkstack(L, 2);
 
438
        static const LuaHashString cmdStr(__FUNCTION__);
 
439
        if (!PushCallIn(cmdStr)) {
 
440
                return;
 
441
        }
 
442
 
 
443
        // call the routine
 
444
        luaUI->RunCallInUnsynced(cmdStr, 0, 0);
 
445
}
 
446
 
 
447
void LuaLobby::Aggreement(const std::string& text)
 
448
{
 
449
        LUA_CALL_IN_CHECK(L);
 
450
        lua_checkstack(L, 3);
 
451
        static const LuaHashString cmdStr(__FUNCTION__);
 
452
        if (!PushCallIn(cmdStr)) {
 
453
                return;
 
454
        }
 
455
 
 
456
        lua_pushstring(L, text.c_str());
 
457
 
 
458
        // call the routine
 
459
        luaUI->RunCallInUnsynced(cmdStr, 1, 0);
 
460
}
 
461
 
 
462
void LuaLobby::Motd(const std::string& text)
 
463
{
 
464
        LUA_CALL_IN_CHECK(L);
 
465
        lua_checkstack(L, 3);
 
466
        static const LuaHashString cmdStr(__FUNCTION__);
 
467
        if (!PushCallIn(cmdStr)) {
 
468
                return;
 
469
        }
 
470
 
 
471
        lua_pushstring(L, text.c_str());
 
472
 
 
473
        // call the routine
 
474
        luaUI->RunCallInUnsynced(cmdStr, 1, 0);
 
475
}
 
476
 
 
477
void LuaLobby::ServerMessage(const std::string& text)
 
478
{
 
479
        LUA_CALL_IN_CHECK(L);
 
480
        lua_checkstack(L, 3);
 
481
        static const LuaHashString cmdStr(__FUNCTION__);
 
482
        if (!PushCallIn(cmdStr)) {
 
483
                return;
 
484
        }
 
485
 
 
486
        lua_pushstring(L, text.c_str());
 
487
 
 
488
        // call the routine
 
489
        luaUI->RunCallInUnsynced(cmdStr, 1, 0);
 
490
}
 
491
 
 
492
void LuaLobby::ServerMessageBox(const std::string& text, const std::string& url)
 
493
{
 
494
        LUA_CALL_IN_CHECK(L);
 
495
        lua_checkstack(L, 4);
 
496
        static const LuaHashString cmdStr(__FUNCTION__);
 
497
        if (!PushCallIn(cmdStr)) {
 
498
                return;
 
499
        }
 
500
 
 
501
        lua_pushstring(L, text.c_str());
 
502
        lua_pushstring(L, url.c_str());
 
503
 
 
504
        // call the routine
 
505
        luaUI->RunCallInUnsynced(cmdStr, 2, 0);
 
506
}
 
507
 
 
508
void LuaLobby::AddUser(const std::string& name, const std::string& country, int cpu)
 
509
{
 
510
        LUA_CALL_IN_CHECK(L);
 
511
        lua_checkstack(L, 5);
 
512
        static const LuaHashString cmdStr(__FUNCTION__);
 
513
        if (!PushCallIn(cmdStr)) {
 
514
                return;
 
515
        }
 
516
 
 
517
        lua_pushstring(L, name.c_str());
 
518
        lua_pushstring(L, country.c_str());
 
519
        lua_pushnumber(L, cpu);
 
520
 
 
521
        // call the routine
 
522
        luaUI->RunCallInUnsynced(cmdStr, 3, 0);
 
523
}
 
524
 
 
525
void LuaLobby::RemoveUser(const std::string& name)
 
526
{
 
527
        LUA_CALL_IN_CHECK(L);
 
528
        lua_checkstack(L, 3);
 
529
        static const LuaHashString cmdStr(__FUNCTION__);
 
530
        if (!PushCallIn(cmdStr)) {
 
531
                return;
 
532
        }
 
533
 
 
534
        lua_pushstring(L, name.c_str());
 
535
 
 
536
        // call the routine
 
537
        luaUI->RunCallInUnsynced(cmdStr, 1, 0);
 
538
}
 
539
 
 
540
void LuaLobby::UserStatusUpdate(const std::string& name, ClientStatus status)
 
541
{
 
542
        LUA_CALL_IN_CHECK(L);
 
543
        lua_checkstack(L, 8);
 
544
        static const LuaHashString cmdStr(__FUNCTION__);
 
545
        if (!PushCallIn(cmdStr)) {
 
546
                return;
 
547
        }
 
548
 
 
549
        lua_pushstring(L, name.c_str());
 
550
        lua_pushboolean(L, status.away);
 
551
        lua_pushboolean(L, status.bot);
 
552
        lua_pushboolean(L, status.ingame);
 
553
        lua_pushboolean(L, status.moderator);
 
554
        lua_pushnumber(L, status.rank);
 
555
 
 
556
        // call the routine
 
557
        luaUI->RunCallInUnsynced(cmdStr, 6, 0);
 
558
}
 
559
 
 
560
void LuaLobby::ChannelInfo(const std::string& channel, unsigned users)
 
561
{
 
562
        LUA_CALL_IN_CHECK(L);
 
563
        lua_checkstack(L, 4);
 
564
        static const LuaHashString cmdStr(__FUNCTION__);
 
565
        if (!PushCallIn(cmdStr)) {
 
566
                return;
 
567
        }
 
568
 
 
569
        lua_pushstring(L, channel.c_str());
 
570
        lua_pushnumber(L, users);
 
571
 
 
572
        // call the routine
 
573
        luaUI->RunCallInUnsynced(cmdStr, 2, 0);
 
574
}
 
575
 
 
576
void LuaLobby::ChannelInfoEnd()
 
577
{
 
578
        LUA_CALL_IN_CHECK(L);
 
579
        lua_checkstack(L, 2);
 
580
        static const LuaHashString cmdStr(__FUNCTION__);
 
581
        if (!PushCallIn(cmdStr)) {
 
582
                return;
 
583
        }
 
584
 
 
585
        // call the routine
 
586
        luaUI->RunCallInUnsynced(cmdStr, 0, 0);
 
587
}
 
588
 
 
589
void LuaLobby::Mutelist(const std::string& channel, std::list<std::string> list)
 
590
{
 
591
        LUA_CALL_IN_CHECK(L);
 
592
        lua_checkstack(L, 4);
 
593
        static const LuaHashString cmdStr(__FUNCTION__);
 
594
        if (!PushCallIn(cmdStr)) {
 
595
                return;
 
596
        }
 
597
 
 
598
        lua_pushstring(L, channel.c_str());
 
599
        lua_newtable(L);
 
600
        int i = 1;
 
601
        for (std::list<std::string>::const_iterator it = list.begin(); it != list.end(); ++it)
 
602
        {
 
603
                lua_pushstring(L, it->c_str());
 
604
                lua_rawseti(L, -2, i++);
 
605
        }
 
606
 
 
607
        // call the routine
 
608
        luaUI->RunCallInUnsynced(cmdStr, 2, 0);
 
609
}
 
610
 
 
611
void LuaLobby::Joined(const std::string& channame)
 
612
{
 
613
        LUA_CALL_IN_CHECK(L);
 
614
        lua_checkstack(L, 3);
 
615
        static const LuaHashString cmdStr(__FUNCTION__);
 
616
        if (!PushCallIn(cmdStr)) {
 
617
                return;
 
618
        }
 
619
 
 
620
        lua_pushstring(L, channame.c_str());
 
621
 
 
622
        // call the routine
 
623
        luaUI->RunCallInUnsynced(cmdStr, 1, 0);
 
624
}
 
625
 
 
626
void LuaLobby::ChannelMember(const std::string& channame, const std::string& name, bool joined)
 
627
{
 
628
        LUA_CALL_IN_CHECK(L);
 
629
        lua_checkstack(L, 5);
 
630
        static const LuaHashString cmdStr(__FUNCTION__);
 
631
        if (!PushCallIn(cmdStr)) {
 
632
                return;
 
633
        }
 
634
 
 
635
        lua_pushstring(L, channame.c_str());
 
636
        lua_pushstring(L, name.c_str());
 
637
        lua_pushboolean(L, joined);
 
638
 
 
639
        // call the routine
 
640
        luaUI->RunCallInUnsynced(cmdStr, 3, 0);
 
641
}
 
642
 
 
643
void LuaLobby::ChannelMemberLeft(const std::string& channame, const std::string& name, const std::string& reason)
 
644
{
 
645
        LUA_CALL_IN_CHECK(L);
 
646
        lua_checkstack(L, 5);
 
647
        static const LuaHashString cmdStr(__FUNCTION__);
 
648
        if (!PushCallIn(cmdStr)) {
 
649
                return;
 
650
        }
 
651
 
 
652
        lua_pushstring(L, channame.c_str());
 
653
        lua_pushstring(L, name.c_str());
 
654
        lua_pushstring(L, reason.c_str());
 
655
 
 
656
        // call the routine
 
657
        luaUI->RunCallInUnsynced(cmdStr, 3, 0);
 
658
}
 
659
 
 
660
void LuaLobby::JoinFailed(const std::string& channame, const std::string& reason)
 
661
{
 
662
        LUA_CALL_IN_CHECK(L);
 
663
        lua_checkstack(L, 4);
 
664
        static const LuaHashString cmdStr(__FUNCTION__);
 
665
        if (!PushCallIn(cmdStr)) {
 
666
                return;
 
667
        }
 
668
 
 
669
        lua_pushstring(L, channame.c_str());
 
670
        lua_pushstring(L, reason.c_str());
 
671
 
 
672
        // call the routine
 
673
        luaUI->RunCallInUnsynced(cmdStr, 2, 0);
 
674
}
 
675
 
 
676
void LuaLobby::ChannelMemberKicked(const std::string& channame, const std::string& user, const std::string& reason)
 
677
{
 
678
        LUA_CALL_IN_CHECK(L);
 
679
        lua_checkstack(L, 5);
 
680
        static const LuaHashString cmdStr(__FUNCTION__);
 
681
        if (!PushCallIn(cmdStr)) {
 
682
                return;
 
683
        }
 
684
 
 
685
        lua_pushstring(L, channame.c_str());
 
686
        lua_pushstring(L, user.c_str());
 
687
        lua_pushstring(L, reason.c_str());
 
688
 
 
689
        // call the routine
 
690
        luaUI->RunCallInUnsynced(cmdStr, 3, 0);
 
691
}
 
692
 
 
693
void LuaLobby::ChannelTopic(const std::string& channame, const std::string& author, long unsigned time, const std::string& topic)
 
694
{
 
695
        LUA_CALL_IN_CHECK(L);
 
696
        lua_checkstack(L, 6);
 
697
        static const LuaHashString cmdStr(__FUNCTION__);
 
698
        if (!PushCallIn(cmdStr)) {
 
699
                return;
 
700
        }
 
701
 
 
702
        lua_pushstring(L, channame.c_str());
 
703
        lua_pushstring(L, author.c_str());
 
704
        lua_pushnumber(L, time/1000);
 
705
        lua_pushstring(L, topic.c_str());
 
706
 
 
707
        // call the routine
 
708
        luaUI->RunCallInUnsynced(cmdStr, 4, 0);
 
709
}
 
710
 
 
711
void LuaLobby::ChannelMessage(const std::string& channel, const std::string& text)
 
712
{
 
713
        LUA_CALL_IN_CHECK(L);
 
714
        lua_checkstack(L, 4);
 
715
        static const LuaHashString cmdStr(__FUNCTION__);
 
716
        if (!PushCallIn(cmdStr)) {
 
717
                return;
 
718
        }
 
719
 
 
720
        lua_pushstring(L, channel.c_str());
 
721
        lua_pushstring(L, text.c_str());
 
722
 
 
723
        // call the routine
 
724
        luaUI->RunCallInUnsynced(cmdStr, 2, 0);
 
725
}
 
726
 
 
727
void LuaLobby::Said(const std::string& channel, const std::string& user, const std::string& text)
 
728
{
 
729
        LUA_CALL_IN_CHECK(L);
 
730
        lua_checkstack(L, 5);
 
731
        static const LuaHashString cmdStr(__FUNCTION__);
 
732
        if (!PushCallIn(cmdStr)) {
 
733
                return;
 
734
        }
 
735
 
 
736
        lua_pushstring(L, channel.c_str());
 
737
        lua_pushstring(L, user.c_str());
 
738
        lua_pushstring(L, text.c_str());
 
739
 
 
740
        // call the routine
 
741
        luaUI->RunCallInUnsynced(cmdStr, 3, 0);
 
742
}
 
743
 
 
744
void LuaLobby::SaidEx(const std::string& channel, const std::string& user, const std::string& text)
 
745
{
 
746
        LUA_CALL_IN_CHECK(L);
 
747
        lua_checkstack(L, 5);
 
748
        static const LuaHashString cmdStr(__FUNCTION__);
 
749
        if (!PushCallIn(cmdStr)) {
 
750
                return;
 
751
        }
 
752
 
 
753
        lua_pushstring(L, channel.c_str());
 
754
        lua_pushstring(L, user.c_str());
 
755
        lua_pushstring(L, text.c_str());
 
756
 
 
757
        // call the routine
 
758
        luaUI->RunCallInUnsynced(cmdStr, 3, 0);
 
759
}
 
760
 
 
761
void LuaLobby::SaidPrivate(const std::string& user, const std::string& text)
 
762
{
 
763
        LUA_CALL_IN_CHECK(L);
 
764
        lua_checkstack(L, 4);
 
765
        static const LuaHashString cmdStr(__FUNCTION__);
 
766
        if (!PushCallIn(cmdStr)) {
 
767
                return;
 
768
        }
 
769
 
 
770
        lua_pushstring(L, user.c_str());
 
771
        lua_pushstring(L, text.c_str());
 
772
 
 
773
        // call the routine
 
774
        luaUI->RunCallInUnsynced(cmdStr, 2, 0);
 
775
}
 
776
 
 
777
void LuaLobby::Disconnected()
 
778
{
 
779
        LUA_CALL_IN_CHECK(L);
 
780
        lua_checkstack(L, 2);
 
781
        static const LuaHashString cmdStr(__FUNCTION__);
 
782
        if (!PushCallIn(cmdStr)) {
 
783
                return;
 
784
        }
 
785
 
 
786
        // call the routine
 
787
        luaUI->RunCallInUnsynced(cmdStr, 0, 0);
 
788
}
 
789
 
 
790
void LuaLobby::NetworkError(const std::string& msg)
 
791
{
 
792
        LUA_CALL_IN_CHECK(L);
 
793
        lua_checkstack(L, 3);
 
794
        static const LuaHashString cmdStr(__FUNCTION__);
 
795
        if (!PushCallIn(cmdStr)) {
 
796
                return;
 
797
        }
 
798
 
 
799
        lua_pushstring(L, msg.c_str());
 
800
 
 
801
        // call the routine
 
802
        luaUI->RunCallInUnsynced(cmdStr, 1, 0);
 
803
}
 
804
 
 
805
/******************************************************************************/
 
806
/******************************************************************************/