Skip to content

Commit

Permalink
* Allowed access to player names on the unsynced side of lua scripts
Browse files Browse the repository at this point in the history
git-svn-id: https://spring.clan-sy.com/svn/spring/trunk@3750 37977431-3df6-0310-b722-df95706aa16b
  • Loading branch information
trepan committed May 14, 2007
1 parent 1f662f9 commit 66fa657
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
9 changes: 7 additions & 2 deletions rts/Game/WordCompletion.cpp
@@ -1,6 +1,11 @@
// WordCompletion.cpp: implementation of the CWordCompletion class.
//
//////////////////////////////////////////////////////////////////////
//
// TODO: replace 'WordProperties' with regex/glob expressions
// ex: '.give [0-9]* armcom'
//


#include "StdAfx.h"
#include "WordCompletion.h"
Expand Down Expand Up @@ -142,8 +147,8 @@ vector<string> CWordCompletion::Complete(string& msg) const
if (cmp < 0) continue;
if (cmp > 0) break;
if ((!it->second.startOfLine || startOfLine) &&
(!it->second.unitName || unitName) &&
(!it->second.minimap || minimap)) {
(!it->second.unitName || unitName) &&
(!it->second.minimap || minimap)) {
partials.push_back(it->first);
}
}
Expand Down
6 changes: 6 additions & 0 deletions rts/Lua/LuaHandleSynced.cpp
Expand Up @@ -886,19 +886,25 @@ int CLuaHandleSynced::UnsyncedXCall(lua_State* srcState, const string& funcName)
if (!diffStates) {
lua_insert(L, 1); // move the function to the beginning
// call the function
synced = false;
if (!RunCallIn(cmdStr, argCount, LUA_MULTRET)) {
synced = true;
lua_settop(L, top);
return 0;
}
synced = true;
retCount = lua_gettop(L) - top;
}
else {
LuaUtils::CopyData(L, srcState, argCount);

// call the function
synced = false;
if (!RunCallIn(cmdStr, argCount, LUA_MULTRET)) {
synced = true;
return 0;
}
synced = true;
retCount = lua_gettop(L) - top;

lua_settop(srcState, 0);
Expand Down
2 changes: 1 addition & 1 deletion rts/Lua/LuaSyncedRead.cpp
Expand Up @@ -1077,7 +1077,7 @@ int LuaSyncedRead::GetPlayerInfo(lua_State* L)
}

// no player names for synchronized scripts
if (CLuaHandle::GetActiveHandle()->GetUserMode()) {
if (!CLuaHandle::GetActiveHandle()->GetSynced()) {
lua_pushstring(L, player->playerName.c_str());
} else {
HSTR_PUSH(L, "SYNCED_NONAME");
Expand Down
5 changes: 5 additions & 0 deletions rts/Lua/LuaSyncedRead.h
Expand Up @@ -142,6 +142,11 @@ class LuaSyncedRead {
static int TestBuildOrder(lua_State* L);
static int Pos2BuildPos(lua_State* L);

static int TraceRay(lua_State* L); // not implemented
static int TraceRayUnits(lua_State* L); // not implemented
static int TraceRayFeatures(lua_State* L); // not implemented
static int TraceRayGround(lua_State* L); // not implemented

static int GetPositionLosState(lua_State* L);
};

Expand Down

0 comments on commit 66fa657

Please sign in to comment.