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

« back to all changes in this revision

Viewing changes to rts/Lua/LuaGaia.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
 
1
3
#include "StdAfx.h"
2
 
// LuaGaia.cpp: implementation of the CLuaGaia class.
3
 
//
4
 
//////////////////////////////////////////////////////////////////////
5
4
 
6
5
#include <set>
7
6
#include <cctype>
19
18
#include "LuaWeaponDefs.h"
20
19
#include "LuaOpenGL.h"
21
20
 
22
 
#include "Rendering/UnitModels/UnitDrawer.h"
 
21
#include "Rendering/UnitDrawer.h"
23
22
#include "Sim/Misc/GlobalSynced.h"
24
23
#include "Sim/Misc/TeamHandler.h"
25
24
#include "Sim/Units/Unit.h"
33
32
 
34
33
CLuaGaia* luaGaia = NULL;
35
34
 
36
 
string CLuaGaia::configString;
37
 
 
38
35
static const char* LuaGaiaSyncedFilename   = "LuaGaia/main.lua";
39
36
static const char* LuaGaiaUnsyncedFilename = "LuaGaia/draw.lua";
40
37
 
62
59
}
63
60
 
64
61
 
65
 
bool CLuaGaia::SetConfigString(const string& cfg)
66
 
{
67
 
        configString = cfg;
68
 
        if ((cfg == "0") || (cfg == "disabled")) {
69
 
                return false;
70
 
        }
71
 
        return true;
72
 
}
73
 
 
74
 
 
75
62
/******************************************************************************/
76
63
/******************************************************************************/
77
64
 
78
65
CLuaGaia::CLuaGaia()
79
 
: CLuaHandleSynced("LuaGaia", LUA_HANDLE_ORDER_GAIA, ".luagaia ")
 
66
: CLuaHandleSynced("LuaGaia", LUA_HANDLE_ORDER_GAIA)
80
67
{
81
68
        luaGaia = this;
82
69
 
109
96
 
110
97
bool CLuaGaia::AddSyncedCode()
111
98
{
112
 
        lua_getglobal(L, "Script");
113
 
        LuaPushNamedCFunc(L, "GetConfigString", GetConfigString);
114
 
        lua_pop(L, 1);
115
 
 
116
99
        return true;
117
100
}
118
101
 
119
102
 
120
103
bool CLuaGaia::AddUnsyncedCode()
121
104
{
122
 
        lua_pushstring(L, "UNSYNCED");
123
 
        lua_gettable(L, LUA_REGISTRYINDEX);
124
 
        lua_pushstring(L, "Script");
125
 
        lua_rawget(L, -2);
126
 
        LuaPushNamedCFunc(L, "GetConfigString", GetConfigString);
127
 
        lua_pop(L, 1);
 
105
        /*lua_pushstring(L, "UNSYNCED");
 
106
        lua_gettable(L, LUA_REGISTRYINDEX);*/
128
107
 
129
108
        return true;
130
109
}
131
110
 
132
 
 
133
 
/******************************************************************************/
134
 
 
135
 
int CLuaGaia::GetConfigString(lua_State* L)
136
 
{
137
 
        lua_pushlstring(L, configString.c_str(), configString.size());
138
 
        return 1;
139
 
}
140
 
 
141
 
 
142
111
/******************************************************************************/
143
112
/******************************************************************************/