Merge with develop

--HG--
branch : compatibility-develop
This commit is contained in:
kervala 2015-11-13 19:52:35 +01:00
commit 7f62faa794
77 changed files with 833 additions and 467 deletions

View file

@ -239,6 +239,7 @@ namespace NLGUI
bool isNil(int index = -1);
bool isBoolean(int index = -1);
bool isNumber(int index = -1);
bool isInteger(int index = -1);
bool isString(int index = -1);
bool isTable(int index = -1);
bool isFunction(int index = -1);
@ -248,6 +249,7 @@ namespace NLGUI
// converting then getting a value from the stack
bool toBoolean(int index = -1);
lua_Number toNumber(int index = -1);
lua_Integer toInteger(int index = -1);
const char *toString(int index = -1);
void toString(int index, std::string &str); // convert to a std::string, with a NULL check.
size_t strlen(int index = -1);
@ -259,11 +261,13 @@ namespace NLGUI
* If conversion fails then an exception is thrown (with optional msg)
*/
bool getTableBooleanValue(const char *name, bool defaultValue= false);
double getTableNumberValue(const char *name, double defaultValue= 0);
double getTableNumberValue(const char *name, double defaultValue= 0.0);
sint64 getTableIntegerValue(const char *name, sint64 defaultValue= 0);
const char *getTableStringValue(const char *name, const char *defaultValue= NULL);
// pushing value onto the stack
void push(bool value);
void push(lua_Number value);
void push(lua_Integer value);
void push(const char *str);
void push(const char *str, int length);
void push(const std::string &str);

View file

@ -172,6 +172,18 @@ inline bool CLuaState::isNumber(int index)
return lua_isnumber(_State, index) != 0;
}
//================================================================================
inline bool CLuaState::isInteger(int index)
{
//H_AUTO(Lua_CLuaState_isInteger)
checkIndex(index);
#if LUA_VERSION_NUM >= 503
return lua_isinteger(_State, index) != 0;
#else
return lua_isnumber(_State, index) != 0;
#endif
}
//================================================================================
inline bool CLuaState::isString(int index)
{
@ -236,6 +248,14 @@ inline lua_Number CLuaState::toNumber(int index)
return lua_tonumber(_State, index);
}
//================================================================================
inline lua_Integer CLuaState::toInteger(int index)
{
//H_AUTO(Lua_CLuaState_toInteger)
checkIndex(index);
return lua_tointeger(_State, index);
}
//================================================================================
inline const char *CLuaState::toString(int index)
{
@ -309,6 +329,14 @@ inline void CLuaState::push(lua_Number value)
lua_pushnumber(_State, value);
}
//================================================================================
inline void CLuaState::push(lua_Integer value)
{
//H_AUTO(Lua_CLuaState_push)
nlverify( lua_checkstack(_State, 1) );
lua_pushinteger(_State, value);
}
//================================================================================
inline void CLuaState::push(const char *str)
{

View file

@ -31,8 +31,8 @@ namespace NLGUI
class CLuaManager
{
public:
~CLuaManager();
/// Get or create singleton
static CLuaManager& getInstance()
{
if( instance == NULL )
@ -42,6 +42,9 @@ namespace NLGUI
return *instance;
}
/// Release singleton
static void releaseInstance();
/// Enables attaching the Lua debugger in the CLuaState instance, only matters on startup.
static void enableLuaDebugging(){ debugLua = true; }
@ -65,6 +68,7 @@ namespace NLGUI
private:
CLuaManager();
~CLuaManager();
static CLuaManager *instance;
static bool debugLua;

View file

@ -80,6 +80,7 @@ namespace NLGUI
const char *getTypename() const;
bool isNil() const;
bool isNumber() const;
bool isInteger() const;
bool isBoolean() const;
bool isString() const;
bool isFunction() const;
@ -94,6 +95,7 @@ namespace NLGUI
NLMISC::CRGBA toRGBA() const; // default to black if not a crgba
bool toBoolean() const;
lua_Number toNumber() const;
lua_Integer toInteger() const;
std::string toString() const;
lua_CFunction toCFunction() const;
void *toUserData() const;
@ -102,6 +104,8 @@ namespace NLGUI
operator bool() const;
operator float() const;
operator double() const;
operator sint32() const;
operator sint64() const;
operator std::string() const;
/** create a sub table for this object, with a string as a key
* This object must be a table or an exception if thrown

View file

@ -169,25 +169,25 @@ namespace NLGUI
if( _ColSelR.getNodePtr() != NULL )
s = _ColSelR.getNodePtr()->getFullName();
else
s = "";
s.clear();
xmlSetProp( node, BAD_CAST "dbcolr", BAD_CAST s.c_str() );
if( _ColSelG.getNodePtr() != NULL )
s = _ColSelG.getNodePtr()->getFullName();
else
s = "";
s.clear();
xmlSetProp( node, BAD_CAST "dbcolg", BAD_CAST s.c_str() );
if( _ColSelB.getNodePtr() != NULL )
s = _ColSelB.getNodePtr()->getFullName();
else
s = "";
s.clear();
xmlSetProp( node, BAD_CAST "dbcolb", BAD_CAST s.c_str() );
if( _ColSelA.getNodePtr() != NULL )
s = _ColSelA.getNodePtr()->getFullName();
else
s = "";
s.clear();
xmlSetProp( node, BAD_CAST "dbcola", BAD_CAST s.c_str() );
return node;

View file

@ -519,17 +519,17 @@ namespace NLGUI
// Read Action handlers
prop = (char*) xmlGetProp( node, (xmlChar*)"onscroll" );
if (prop) _AHOnScroll = NLMISC::strlwr(prop.str());
if (prop) _AHOnScroll = NLMISC::toLower(prop.str());
prop = (char*) xmlGetProp( node, (xmlChar*)"params" );
if (prop) _AHOnScrollParams = string((const char*)prop);
//
prop = (char*) xmlGetProp( node, (xmlChar*)"onscrollend" );
if (prop) _AHOnScrollEnd = NLMISC::strlwr(prop.str());
if (prop) _AHOnScrollEnd = NLMISC::toLower(prop.str());
prop = (char*) xmlGetProp( node, (xmlChar*)"end_params" );
if (prop) _AHOnScrollEndParams = string((const char*)prop);
//
prop = (char*) xmlGetProp( node, (xmlChar*)"onscrollcancel" );
if (prop) _AHOnScrollCancel = NLMISC::strlwr(prop.str());
if (prop) _AHOnScrollCancel = NLMISC::toLower(prop.str());
prop = (char*) xmlGetProp( node, (xmlChar*)"cancel_params" );
if (prop) _AHOnScrollCancelParams = string((const char*)prop);

View file

@ -543,7 +543,7 @@ namespace NLGUI
CLuaIHM::checkArgTypeUCString(ls, funcName, 2);
ucstring text;
nlverify(CLuaIHM::pop(ls, text));
setText((uint) ls.toNumber(1), text);
setText((uint) ls.toInteger(1), text);
return 0;
}
@ -556,7 +556,7 @@ namespace NLGUI
CLuaIHM::checkArgTypeUCString(ls, funcName, 2);
ucstring text;
nlverify(CLuaIHM::pop(ls, text));
insertText((uint) ls.toNumber(1), text);
insertText((uint) ls.toInteger(1), text);
return 0;
}
@ -569,7 +569,7 @@ namespace NLGUI
CLuaIHM::checkArgTypeUCString(ls, funcName, 2);
ucstring texture;
nlverify(CLuaIHM::pop(ls, texture));
setTexture((uint) ls.toNumber(1), texture);
setTexture((uint) ls.toInteger(1), texture);
return 0;
}
@ -579,7 +579,7 @@ namespace NLGUI
const char *funcName = "setText";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
CLuaIHM::push(ls, getText((uint) ls.toNumber(1)));
CLuaIHM::push(ls, getText((uint) ls.toInteger(1)));
return 1;
}
@ -589,7 +589,7 @@ namespace NLGUI
const char *funcName = "removeText";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
removeText((uint) ls.toNumber(1));
removeText((uint) ls.toInteger(1));
return 0;
}

View file

@ -4820,7 +4820,7 @@ namespace NLGUI
const char *funcName = "blink";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
enableBlink((uint) ls.toNumber(1));
enableBlink((uint) ls.toInteger(1));
return 0;
}

View file

@ -606,11 +606,7 @@ namespace NLGUI
}
prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_r" );
if (prop)
{
string tmp = (const char *) prop;
_ListMenuRight = strlwr(tmp);
}
if (prop) _ListMenuRight = toLower((const char *) prop);
prop = (char*) xmlGetProp( cur, (xmlChar*)"max_historic" );
if (prop) fromString((const char*)prop, _MaxHistoric);

View file

@ -202,7 +202,7 @@ namespace NLGUI
const char *funcName = "enlargeColumns";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
enlargeColumns((sint32) ls.toNumber(1));
enlargeColumns((sint32) ls.toInteger(1));
return 0;
}
@ -212,7 +212,7 @@ namespace NLGUI
const char *funcName = "resizeColumnsAndContainer";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
resizeColumnsAndContainer((sint32) ls.toNumber(1));
resizeColumnsAndContainer((sint32) ls.toInteger(1));
return 0;
}

View file

@ -772,8 +772,7 @@ namespace NLGUI
cellParams.NoWrap = true; \
if (present[prefix##_ALIGN] && value[prefix##_ALIGN]) \
{ \
string align = value[prefix##_ALIGN]; \
align = strlwr(align); \
string align = toLower(value[prefix##_ALIGN]); \
if (align == "left") \
cellParams.Align = CGroupCell::Left; \
if (align == "center") \
@ -783,8 +782,7 @@ namespace NLGUI
} \
if (present[prefix##_VALIGN] && value[prefix##_VALIGN]) \
{ \
string align = value[prefix##_VALIGN]; \
align = strlwr(align); \
string align = toLower(value[prefix##_VALIGN]); \
if (align == "top") \
cellParams.VAlign = CGroupCell::Top; \
if (align == "middle") \
@ -1182,7 +1180,7 @@ namespace NLGUI
if (it != styles.end())
{
string image = it->second;
string::size_type texExt = strlwr(image).find("url(");
string::size_type texExt = toLower(image).find("url(");
// Url image
if (texExt != string::npos)
// Remove url()
@ -1321,8 +1319,7 @@ namespace NLGUI
if (present[MY_HTML_INPUT_ALT] && value[MY_HTML_INPUT_ALT])
tooltip = value[MY_HTML_INPUT_ALT];
string type = value[MY_HTML_INPUT_TYPE];
type = strlwr (type);
string type = toLower(value[MY_HTML_INPUT_TYPE]);
if (type == "image")
{
// The submit button
@ -1668,7 +1665,7 @@ namespace NLGUI
{
nlinfo("found background-image %s", it->second.c_str());
string image = (*it).second;
string::size_type texExt = strlwr(image).find("url(");
string::size_type texExt = toLower(image).find("url(");
// Url image
if (texExt != string::npos)
{
@ -3826,7 +3823,7 @@ namespace NLGUI
// folder used for images cache
static const string cacheDir = "cache";
string::size_type protocolPos = strlwr(result).find("://");
string::size_type protocolPos = toLower(result).find("://");
if (protocolPos != string::npos)
{
@ -3840,7 +3837,7 @@ namespace NLGUI
else
{
// Url is a file ?
if (strlwr(result).find("file:") == 0)
if (toLower(result).find("file:") == 0)
{
result = result.substr(5, result.size()-5);
}
@ -3857,7 +3854,7 @@ namespace NLGUI
{
// Normalize the path
if (isUrl)
//result = "file:"+strlwr(CPath::standardizePath (CPath::getFullPath (CFile::getPath(result)))+CFile::getFilename(result));*/
//result = "file:"+toLower(CPath::standardizePath (CPath::getFullPath (CFile::getPath(result)))+CFile::getFilename(result));*/
result = "file:/"+tmp;
else
result = tmp;
@ -4114,7 +4111,7 @@ namespace NLGUI
void CGroupHTML::doBrowseLocalFile(const std::string &uri)
{
std::string filename;
if (strlwr(uri).find("file:/") == 0)
if (toLower(uri).find("file:/") == 0)
{
filename = uri.substr(6, uri.size() - 6);
}
@ -4728,7 +4725,7 @@ namespace NLGUI
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
CLuaIHM::checkArgType(ls, funcName, 2, LUA_TTABLE);
uint element_number = (uint)ls.toNumber(1);
uint element_number = (uint)ls.toInteger(1);
std::vector<bool> present;
std::vector<const char *> value;
present.resize(30, false);
@ -4741,7 +4738,7 @@ namespace NLGUI
ENUM_LUA_TABLE(params, it)
{
if (!it.nextKey().isNumber())
if (!it.nextKey().isInteger())
{
nlwarning("%s : bad key encountered with type %s, number expected.", funcName, it.nextKey().getTypename());
continue;
@ -4751,16 +4748,16 @@ namespace NLGUI
nlwarning("%s : bad value encountered with type %s for key %s, string expected.", funcName, it.nextValue().getTypename(), it.nextKey().toString().c_str());
continue;
}
uint idx = (uint)it.nextKey().toNumber();
uint idx = (uint)it.nextKey().toInteger();
present.insert(present.begin() + (uint)it.nextKey().toNumber(), true);
present.insert(present.begin() + (uint)it.nextKey().toInteger(), true);
string str = it.nextValue().toString();
size_t size = str.size() + 1;
char * buffer = new char[ size ];
strncpy(buffer, str.c_str(), size );
value.insert(value.begin() + (uint)it.nextKey().toNumber(), buffer);
value.insert(value.begin() + (uint)it.nextKey().toInteger(), buffer);
}
beginElement(element_number, present, value);
@ -4778,7 +4775,7 @@ namespace NLGUI
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
uint element_number = (uint)ls.toNumber(1);
uint element_number = (uint)ls.toInteger(1);
endElement(element_number);
return 0;
@ -4978,7 +4975,7 @@ namespace NLGUI
else
if (it->first == "text-decoration" || it->first == "text-decoration-line")
{
std::string prop(strlwr(it->second));
std::string prop(toLower(it->second));
style.Underlined = (prop.find("underline") != std::string::npos);
style.StrikeThrough = (prop.find("line-through") != std::string::npos);
}

View file

@ -1224,7 +1224,7 @@ namespace NLGUI
const char *funcName = "getChild";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
sint index = (sint) ls.toNumber(1);
sint index = (sint) ls.toInteger(1);
if(index < 0 || index >= (sint) _Elements.size())
{
CLuaIHM::fails(ls, "getChild : trying to access element %d in list '%s', which has %d elements",
@ -1304,10 +1304,10 @@ namespace NLGUI
ucstring ucText;
ucText.fromUtf8(text);
uint r = (uint) ls.toNumber(2);
uint g = (uint) ls.toNumber(3);
uint b = (uint) ls.toNumber(4);
uint a = (uint) ls.toNumber(5);
uint r = (uint) ls.toInteger(2);
uint g = (uint) ls.toInteger(3);
uint b = (uint) ls.toInteger(4);
uint a = (uint) ls.toInteger(5);
addTextChild(ucText, CRGBA(r, g, b, a));
@ -1344,7 +1344,7 @@ namespace NLGUI
}
else
{
addChildAtIndex(vb, (uint) ls.toNumber(2));
addChildAtIndex(vb, (uint) ls.toInteger(2));
}
return 0;
}

View file

@ -1712,7 +1712,7 @@ namespace NLGUI
const char *funcName = "getSubMenu";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
CLuaIHM::pushUIOnStack(ls, getSubMenu((uint) ls.toNumber(1)));
CLuaIHM::pushUIOnStack(ls, getSubMenu((uint) ls.toInteger(1)));
return 1;
}
@ -1722,8 +1722,8 @@ namespace NLGUI
const char *funcName = "addSubMenu";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
setSubMenu((uint) ls.toNumber(1), new CGroupSubMenu(CViewText::TCtorParam()));
CLuaIHM::pushUIOnStack(ls, getSubMenu((uint) ls.toNumber(1)));
setSubMenu((uint) ls.toInteger(1), new CGroupSubMenu(CViewText::TCtorParam()));
CLuaIHM::pushUIOnStack(ls, getSubMenu((uint) ls.toInteger(1)));
return 1;
}
@ -1733,7 +1733,7 @@ namespace NLGUI
const char *funcName = "getLineId";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
std::string id = getLineId((uint) ls.toNumber(1));
std::string id = getLineId((uint) ls.toInteger(1));
CLuaIHM::push(ls, id);
return 1;
}
@ -1754,7 +1754,7 @@ namespace NLGUI
const char *funcName = "isSeparator";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
ls.push(isSeparator((uint) ls.toNumber(1)));
ls.push(isSeparator((uint) ls.toInteger(1)));
return 1;
}
@ -1785,7 +1785,7 @@ namespace NLGUI
CLuaIHM::checkArgType(ls, funcName, 5, LUA_TSTRING);
ucstring arg2;
nlverify(CLuaIHM::getUCStringOnStack(ls, 2, arg2));
addLineAtIndex((uint) ls.toNumber(1), arg2, ls.toString(3), ls.toString(4), ls.toString(5));
addLineAtIndex((uint) ls.toInteger(1), arg2, ls.toString(3), ls.toString(4), ls.toString(5));
return 0;
}
@ -1803,7 +1803,7 @@ namespace NLGUI
const char *funcName = "addSeparatorAtIndex";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
addSeparatorAtIndex((uint) ls.toNumber(1));
addSeparatorAtIndex((uint) ls.toInteger(1));
return 0;
}
@ -1813,7 +1813,7 @@ namespace NLGUI
const char *funcName = "removeLine";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
removeLine((uint) ls.toNumber(1));
removeLine((uint) ls.toInteger(1));
return 0;
}
@ -1833,7 +1833,7 @@ namespace NLGUI
{
CLuaIHM::fails(ls, "%s : Group required as argument 2", funcName);
}
setUserGroupRight((uint) ls.toNumber(1), group, true);
setUserGroupRight((uint) ls.toInteger(1), group, true);
return 0;
}
@ -1853,7 +1853,7 @@ namespace NLGUI
{
CLuaIHM::fails(ls, "%s : Group required as argument 2", funcName);
}
setUserGroupLeft((uint) ls.toNumber(1), group, true);
setUserGroupLeft((uint) ls.toInteger(1), group, true);
return 0;
}
@ -1864,7 +1864,7 @@ namespace NLGUI
const char *funcName = "getUserGroupRight";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
CLuaIHM::pushUIOnStack(ls, getUserGroupRight((uint) ls.toNumber(1)));
CLuaIHM::pushUIOnStack(ls, getUserGroupRight((uint) ls.toInteger(1)));
return 1;
}
@ -1875,7 +1875,7 @@ namespace NLGUI
const char *funcName = "getUserGroupLeft";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
CInterfaceElement *pIE = getUserGroupLeft((uint) ls.toNumber(1));
CInterfaceElement *pIE = getUserGroupLeft((uint) ls.toInteger(1));
if (pIE)
{
CLuaIHM::pushUIOnStack(ls, pIE);
@ -1890,7 +1890,7 @@ namespace NLGUI
const char *funcName = "setMaxVisibleLine";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
setMaxVisibleLine((uint) ls.toNumber(1));
setMaxVisibleLine((uint) ls.toInteger(1));
return 0;
}
@ -2566,7 +2566,7 @@ namespace NLGUI
const char *funcName = "setMinW";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
setMinW((sint32) ls.toNumber(1));
setMinW((sint32) ls.toInteger(1));
return 0;
}
}

View file

@ -316,7 +316,7 @@ namespace NLGUI
if (tabB)
{
// don't use addTab to avoid selection of new tab
addTab(tabB, (sint) ls.toNumber(2));
addTab(tabB, (sint) ls.toInteger(2));
}
return 0;
}
@ -395,7 +395,7 @@ namespace NLGUI
const char *funcName = "removeTab";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
removeTab((uint) ls.toNumber(1));
removeTab((uint) ls.toInteger(1));
return 0;
}
@ -441,7 +441,7 @@ namespace NLGUI
const char *funcName = "getTabButton";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
CCtrlTabButton* tab = getTabButton((uint) ls.toNumber(1));
CCtrlTabButton* tab = getTabButton((uint) ls.toInteger(1));
if(tab != NULL)
{
CLuaIHM::pushUIOnStack(ls, tab);
@ -562,7 +562,7 @@ namespace NLGUI
const char *funcName = "showTabButton";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
sint showTab = (sint)ls.toNumber(1);
sint showTab = (sint)ls.toInteger(1);
if(showTab>=0 && showTab<(sint)_Buttons.size())
{
@ -770,7 +770,7 @@ namespace NLGUI
const char *funcName = "getGroup";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
CInterfaceGroup* group = getGroup((uint) ls.toNumber(1));
CInterfaceGroup* group = getGroup((uint) ls.toInteger(1));
if(group != NULL)
{
CLuaIHM::pushUIOnStack(ls, group);

View file

@ -1815,7 +1815,7 @@ namespace NLGUI
const char *funcName = "CGroupTree::SNode::luaAddChildAtIndex";
CLuaIHM::checkArgCount(ls, funcName, 2);
CLuaIHM::checkArgType(ls, funcName, 2, LUA_TNUMBER);
addChildAtIndex(luaGetNodeOnStack(ls, funcName), (sint) ls.toNumber(2));
addChildAtIndex(luaGetNodeOnStack(ls, funcName), (sint) ls.toInteger(2));
return 0;
}
@ -1847,7 +1847,7 @@ namespace NLGUI
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
//
sint index = (sint) ls.toNumber(1);
sint index = (sint) ls.toInteger(1);
if (index < 0 || index >= (sint) Children.size())
{
std::string range = Children.empty() ? "<empty>" : toString("[0, %d]", Children.size() - 1);
@ -1890,7 +1890,7 @@ namespace NLGUI
{
CLuaIHM::checkArgType(ls, "CGroupTree::selectLine", 1, LUA_TNUMBER);
CLuaIHM::checkArgType(ls, "CGroupTree::selectLine", 2, LUA_TBOOLEAN);
selectLine((uint) ls.toNumber(1), ls.toBoolean(2));
selectLine((uint) ls.toInteger(1), ls.toBoolean(2));
return 0;
}

View file

@ -55,8 +55,7 @@ namespace NLGUI
if (ptr) _Dynamic = CInterfaceElement::convertBool (ptr);
ptr = xmlGetProp (cur, (xmlChar*)"type");
string sTmp = ptr.str();
sTmp = strlwr(sTmp);
string sTmp = toLower(ptr.str());
if (sTmp == "linear")
_Type = Track_Linear;
else if (sTmp == "bezier")

View file

@ -312,8 +312,7 @@ namespace NLGUI
ptr = (char*) xmlGetProp( cur, (xmlChar*)"max_sizeparent" );
if (ptr)
{
string idparent = ptr.str();
idparent = NLMISC::strlwr(idparent);
string idparent = NLMISC::toLower(ptr.str());
if (idparent != "parent")
{
if (parentGroup)
@ -1184,7 +1183,7 @@ namespace NLGUI
const char *funcName = "CInterfaceGroup::getGroup";
CLuaIHM::checkArgCount(ls, "CInterfaceGroup::getGroup", 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
uint index = (uint) ls.toNumber(1);
uint index = (uint) ls.toInteger(1);
if (index >= _ChildrenGroups.size())
{
CLuaIHM::fails(ls, "getGroup : try to index group %s, but there are only %d son groups", ls.toString(1), (int) _ChildrenGroups.size());

View file

@ -127,8 +127,7 @@ namespace NLGUI
// ***************************************************************************
const CInterfaceOptionValue &CInterfaceOptions::getValue(const string &sParamName) const
{
string sLwrParamName = strlwr (sParamName);
std::map<std::string, CInterfaceOptionValue>::const_iterator it = _ParamValue.find (sLwrParamName);
std::map<std::string, CInterfaceOptionValue>::const_iterator it = _ParamValue.find (toLower(sParamName));
if (it != _ParamValue.end())
return it->second;
else

View file

@ -1359,6 +1359,9 @@ namespace NLGUI
{
CXMLAutoPtr ptr((const char*) xmlGetProp( cur, (xmlChar*)"node" ));
if (!ptr) return false;
string stmp2 = toLower(string((const char*)ptr));
CInterfaceElement *pEltFound = NULL;
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
for (uint32 i = 0; i < _MasterGroups.size(); ++i)
@ -1367,8 +1370,8 @@ namespace NLGUI
for (uint32 j = 0; j < rMG.Group->getGroups().size(); ++j)
{
CInterfaceGroup *pIG = rMG.Group->getGroups()[j];
string stmp = strlwr(pIG->getId().substr(pIG->getId().rfind(':')+1,pIG->getId().size()));
string stmp2 = strlwr(string((const char*)ptr));
string stmp = toLower(pIG->getId().substr(pIG->getId().rfind(':')+1,pIG->getId().size()));
if (stmp == stmp2)
{
pEltFound = pIG;
@ -1408,6 +1411,9 @@ namespace NLGUI
{
CXMLAutoPtr ptr((const char*) xmlGetProp( cur, (xmlChar*)"node" ));
if (!ptr) return false;
string stmp2 = toLower(string((const char*)ptr));
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
CInterfaceElement *pEltFound = NULL;
for (uint32 i = 0; i < _MasterGroups.size(); ++i)
@ -1416,8 +1422,7 @@ namespace NLGUI
for (uint32 j = 0; j < rMG.Group->getGroups().size(); ++j)
{
CInterfaceGroup *pIG = rMG.Group->getGroups()[j];
string stmp = strlwr(pIG->getId().substr(pIG->getId().rfind(':')+1,pIG->getId().size()));
string stmp2 = strlwr(string((const char*)ptr));
string stmp = toLower(pIG->getId().substr(pIG->getId().rfind(':')+1,pIG->getId().size()));
if (stmp == stmp2)
{
pEltFound = pIG;
@ -1600,6 +1605,9 @@ namespace NLGUI
{
CXMLAutoPtr ptr((const char*) xmlGetProp( cur, (xmlChar*)"node" ));
if (!ptr) return false;
string stmp2 = toLower(string((const char*)ptr));
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
CInterfaceElement *pEltFound = NULL;
for (uint32 i = 0; i < _MasterGroups.size(); ++i)
@ -1608,8 +1616,8 @@ namespace NLGUI
for (uint32 j = 0; j < rMG.Group->getGroups().size(); ++j)
{
CInterfaceGroup *pIG = rMG.Group->getGroups()[j];
string stmp = strlwr(pIG->getId().substr(pIG->getId().rfind(':')+1,pIG->getId().size()));
string stmp2 = strlwr(string((const char*)ptr));
string stmp = toLower(pIG->getId().substr(pIG->getId().rfind(':')+1,pIG->getId().size()));
if (stmp == stmp2)
{
pEltFound = pIG;

View file

@ -623,6 +623,23 @@ namespace NLGUI
return result;
}
// ***************************************************************************
sint64 CLuaState::getTableIntegerValue(const char *name, sint64 defaultValue)
{
//H_AUTO(Lua_CLuaState_getTableIntegerValue)
nlassert(name);
push(name);
getTable(-2);
if (isNil())
{
pop();
return defaultValue;
}
sint64 result = toInteger(-1);
pop();
return result;
}
// ***************************************************************************
const char *CLuaState::getTableStringValue(const char *name, const char *defaultValue)
{

View file

@ -231,20 +231,24 @@ namespace NLGUI
}
#if LUA_VERSION_NUM < 503
#define lua_isinteger(a, b) lua_isnumber(a, b)
#endif
// ***************************************************************************
#define LUA_REGISTER_BASIC(_type_) \
luabind::detail::yes_t is_user_defined(luabind::detail::by_value<_type_>); \
_type_ convert_lua_to_cpp(lua_State* L, luabind::detail::by_value<_type_>, int index) \
luabind::detail::yes_t is_user_defined(luabind::detail::by_value<_type_>); \
_type_ convert_lua_to_cpp(lua_State* L, luabind::detail::by_value<_type_>, int index) \
{ \
return (_type_)lua_tonumber(L, index); \
return (_type_)lua_tointeger(L, index); \
} \
int match_lua_to_cpp(lua_State* L, luabind::detail::by_value<_type_>, int index) \
int match_lua_to_cpp(lua_State* L, luabind::detail::by_value<_type_>, int index) \
{ \
if (lua_isnumber(L, index)) return 0; else return -1; \
if (lua_isinteger(L, index)) return 0; else return -1; \
} \
void convert_cpp_to_lua(lua_State* L, const _type_& v) \
void convert_cpp_to_lua(lua_State* L, const _type_& v) \
{ \
lua_pushnumber(L, (double)v); \
lua_pushinteger(L, (double)v); \
}
// Basic LUA types
@ -258,8 +262,6 @@ namespace NLGUI
LUA_REGISTER_BASIC(uint16)
LUA_REGISTER_BASIC(sint32)
LUA_REGISTER_BASIC(uint32)
// LUA_REGISTER_BASIC(sint)
// LUA_REGISTER_BASIC(uint)
}
}
@ -1381,7 +1383,7 @@ namespace NLGUI
ls.push( (reflectedObject.*(property.GetMethod.GetBool))() );
break;
case CReflectedProperty::SInt32:
ls.push( (lua_Number)(reflectedObject.*(property.GetMethod.GetSInt32))() );
ls.push( (lua_Integer)(reflectedObject.*(property.GetMethod.GetSInt32))() );
break;
case CReflectedProperty::Float:
ls.push( (lua_Number)(reflectedObject.*(property.GetMethod.GetFloat))() );
@ -1447,13 +1449,13 @@ namespace NLGUI
}
case CReflectedProperty::SInt32:
{
sint32 val= (sint32)ls.toNumber(stackIndex);
sint32 val= (sint32)ls.toInteger(stackIndex);
(target.*(property.SetMethod.SetSInt32))(val);
return;
}
case CReflectedProperty::UInt32:
{
uint32 val= (uint32)ls.toNumber(stackIndex);
uint32 val= (uint32)ls.toInteger(stackIndex);
(target.*(property.SetMethod.SetUInt32))(val);
return;
}
@ -1474,7 +1476,7 @@ namespace NLGUI
{
ucstring val;
// Additionaly return of CInterfaceExpr may be std::string... test std string too
if(ls.isString() || ls.isNumber())
if(ls.isString() || ls.isNumber() || ls.isInteger())
{
std::string str;
ls.toString(stackIndex, str);

View file

@ -33,8 +33,20 @@ namespace NLGUI
CLuaManager::~CLuaManager()
{
delete luaState;
luaState = NULL;
if (luaState)
{
delete luaState;
luaState = NULL;
}
}
void CLuaManager::releaseInstance()
{
if (instance)
{
delete instance;
instance = NULL;
}
}
bool CLuaManager::executeLuaScript( const std::string &luaScript, bool smallScript )
@ -60,7 +72,8 @@ namespace NLGUI
void CLuaManager::ResetLuaState()
{
delete luaState;
if (luaState) delete luaState;
luaState = new CLuaState( debugLua );
}

View file

@ -150,7 +150,8 @@ namespace NLGUI
// *************************************************
bool CLuaObject::isNil() const { push(); bool result = _LuaState->isNil(); _LuaState->pop(); return result; }
bool CLuaObject::isNumber() const { push(); bool result = _LuaState->isNumber(); _LuaState->pop(); return result; }
bool CLuaObject::isBoolean() const { push(); bool result = _LuaState->isBoolean(); _LuaState->pop(); return result; }
bool CLuaObject::isInteger() const { push(); bool result = _LuaState->isInteger(); _LuaState->pop(); return result; }
bool CLuaObject::isBoolean() const { push(); bool result = _LuaState->isBoolean(); _LuaState->pop(); return result; }
bool CLuaObject::isString() const { push(); bool result = _LuaState->isString(); _LuaState->pop(); return result; }
bool CLuaObject::isFunction() const { push(); bool result = _LuaState->isFunction(); _LuaState->pop(); return result; }
bool CLuaObject::isCFunction() const { push(); bool result = _LuaState->isCFunction(); _LuaState->pop(); return result; }
@ -168,6 +169,7 @@ namespace NLGUI
// *************************************************
bool CLuaObject::toBoolean() const { push(); bool result = _LuaState->toBoolean(); _LuaState->pop(); return result; }
lua_Number CLuaObject::toNumber() const { push(); lua_Number result = _LuaState->toNumber(); _LuaState->pop(); return result; }
lua_Integer CLuaObject::toInteger() const { push(); lua_Integer result = _LuaState->toInteger(); _LuaState->pop(); return result; }
std::string CLuaObject::toString() const
{
push();
@ -194,6 +196,8 @@ namespace NLGUI
CLuaObject::operator bool() const { return toBoolean(); }
CLuaObject::operator float() const { return (float) toNumber(); }
CLuaObject::operator double() const { return (double) toNumber(); }
CLuaObject::operator sint32() const { return (sint32) toInteger(); }
CLuaObject::operator sint64() const { return (sint64) toInteger(); }
CLuaObject::operator std::string() const { return toString(); }

View file

@ -84,56 +84,43 @@ namespace NLGUI
_OffsetY = getY();
prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_default");
if (prop) _TxDefault = (const char *) prop;
_TxDefault = NLMISC::strlwr (_TxDefault);
if (prop) _TxDefault = NLMISC::toLower ((const char *) prop);
prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_move_window");
if (prop) _TxMoveWindow = (const char *) prop;
_TxMoveWindow = NLMISC::strlwr (_TxMoveWindow);
if (prop) _TxMoveWindow = NLMISC::toLower ((const char *) prop);
prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_resize_BR_TL");
if (prop) _TxResizeBRTL = (const char *) prop;
_TxResizeBRTL = NLMISC::strlwr (_TxResizeBRTL);
if (prop) _TxResizeBRTL = NLMISC::toLower ((const char *) prop);
prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_resize_BL_TR");
if (prop) _TxResizeBLTR = (const char *) prop;
_TxResizeBLTR = NLMISC::strlwr (_TxResizeBLTR);
if (prop) _TxResizeBLTR = NLMISC::toLower ((const char *) prop);
prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_resize_TB");
if (prop) _TxResizeTB = (const char *) prop;
_TxResizeTB = NLMISC::strlwr (_TxResizeTB);
if (prop) _TxResizeTB = NLMISC::toLower ((const char *) prop);
prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_resize_LR");
if (prop) _TxResizeLR = (const char *) prop;
_TxResizeLR = NLMISC::strlwr (_TxResizeLR);
if (prop) _TxResizeLR = NLMISC::toLower ((const char *) prop);
prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_rotate");
if (prop) _TxRotate = (const char *) prop;
_TxRotate = NLMISC::strlwr (_TxRotate);
if (prop) _TxRotate = NLMISC::toLower ((const char *) prop);
prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_scale");
if (prop) _TxScale = (const char *) prop;
_TxScale = NLMISC::strlwr (_TxScale);
if (prop) _TxScale = NLMISC::toLower ((const char *) prop);
prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_colpick");
if (prop) _TxColPick = (const char *) prop;
_TxColPick = NLMISC::strlwr (_TxColPick);
if (prop) _TxColPick = NLMISC::toLower ((const char *) prop);
prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_pan");
if (prop) _TxPan = (const char *) prop;
_TxPan = NLMISC::strlwr (_TxPan);
if (prop) _TxPan = NLMISC::toLower ((const char *) prop);
prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_can_pan");
if (prop) _TxCanPan = (const char *) prop;
_TxCanPan = NLMISC::strlwr (_TxCanPan);
if (prop) _TxCanPan = NLMISC::toLower ((const char *) prop);
prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_pan_r2");
if (prop) _TxPanR2 = (const char *) prop;
_TxPanR2 = NLMISC::strlwr (_TxPanR2);
if (prop) _TxPanR2 = NLMISC::toLower ((const char *) prop);
prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_can_pan_r2");
if (prop) _TxCanPanR2 = (const char *) prop;
_TxCanPanR2 = NLMISC::strlwr (_TxCanPanR2);
if (prop) _TxCanPanR2 = NLMISC::toLower ((const char *) prop);
prop = (char*) xmlGetProp (cur, (xmlChar*)"color");
if (prop) _Color = convertColor(prop);

View file

@ -854,12 +854,11 @@ namespace NLGUI
return;
}
// Look if already existing
string sLwrGTName = strlwr(sGlobalTextureName);
string sLwrGTName = toLower(sGlobalTextureName);
TGlobalTextureList::iterator ite = _GlobalTextures.begin();
while (ite != _GlobalTextures.end())
{
std::string sText = strlwr(ite->Name);
if (sText == sLwrGTName)
if (toLower(ite->Name) == sLwrGTName)
break;
ite++;
}
@ -984,11 +983,11 @@ namespace NLGUI
*/
NL3D::UTexture *CViewRenderer::getGlobalTexture(const std::string &name)
{
string sLwrGTName = strlwr(name);
string sLwrGTName = NLMISC::toLower(name);
TGlobalTextureList::iterator ite = _GlobalTextures.begin();
while (ite != _GlobalTextures.end())
{
std::string sText = strlwr(ite->Name);
std::string sText = NLMISC::toLower(ite->Name);
if (sText == sLwrGTName)
break;
ite++;

View file

@ -734,17 +734,23 @@ void CRGBA::buildFromHLS(float h, float l, float s)
CRGBA CRGBA::stringToRGBA( const char *ptr )
{
if (!ptr)
return NLMISC::CRGBA::White;
if (ptr)
{
int r = 255, g = 255, b = 255, a = 255;
// we need at least 3 integer values to consider string is valid
if (sscanf( ptr, "%d %d %d %d", &r, &g, &b, &a ) >= 3)
{
clamp( r, 0, 255 );
clamp( g, 0, 255 );
clamp( b, 0, 255 );
clamp( a, 0, 255 );
int r = 255, g = 255, b = 255, a = 255;
sscanf( ptr, "%d %d %d %d", &r, &g, &b, &a );
clamp( r, 0, 255 );
clamp( g, 0, 255 );
clamp( b, 0, 255 );
clamp( a, 0, 255 );
return CRGBA( r,g,b,a );
return CRGBA( r,g,b,a );
}
}
return NLMISC::CRGBA::White;
}
std::string CRGBA::toString() const

View file

@ -19,7 +19,7 @@ end
------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------
-- WIDGET TO CHOOSE A COLOR
-- WIDGET TO CHOOSE A COLOR
------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------
@ -29,14 +29,14 @@ function game:mcwChooseColor(title, pal)
local ui = getUICaller();
-- get the color of the button and store it in temporary db location
-- get the color of the button and store it in temporary db location
local rgba = ui.col_normal_rgba;
game.ColorPicker.r = rgba.R;
game.ColorPicker.g = rgba.G;
game.ColorPicker.b = rgba.B;
game.ColorPicker.button = ui;
game.ColorPicker.pal = pal;
-- setup the color picker window
local uiModalWin = getUI('ui:interface:define_mcw_color');
if (game.ColorPicker.pal == 0) then
@ -64,8 +64,8 @@ end
-- called when we have finished choosing the color in the modal window and the chosen color is valid
function game:mcwValidateColor()
if (game.ColorPicker.button == nil) then
return;
if (game.ColorPicker.button == nil) then
return;
end
game.ColorPicker.button.col_normal = game.ColorPicker.r .. ' ' .. game.ColorPicker.g .. ' ' .. game.ColorPicker.b;
--debugInfo(game.ColorPicker.button.col_normal)
@ -108,10 +108,10 @@ end
-- hide all the pages of the config window
function game:configHideAll()
local uiList = {
local uiList = {
'explanation', 'general', 'landscape', 'fx', 'char', 'hud', 'language', 'alpha_colors',
'chat_colors', 'entity_colors', 'in_scene_user', 'in_scene_friend', 'in_scene_enemy',
'in_scene_chat_messages', 'win_colors', 'win_colors_r2', 'mouse', 'keyb', 'vr', 'sound', 'landmark_colors', 'help'
'chat_colors', 'entity_colors', 'in_scene_user', 'in_scene_friend', 'in_scene_enemy',
'in_scene_chat_messages', 'win_colors', 'win_colors_r2', 'mouse', 'keyb', 'vr', 'sound', 'landmark_colors', 'help'
};
for k,v in pairs(uiList) do
@ -127,19 +127,19 @@ function game:configShowOne(strUIToShow)
game:configHideAll();
-- special case : if the display tab was shown, update the aspect ratio if needed
local generalGrp = getUI('ui:interface:game_config:content:general');
local uiGrp = getUI('ui:interface:game_config:content:' .. strUIToShow);
local uiGrp = getUI('ui:interface:game_config:content:' .. strUIToShow);
-- Removed the following code to solve RT n°14720
-- The 'game_config_change_screen_ratio_custom' action handler
-- should only be called if the user changed the apect ratio himself
-- The 'game_config_change_screen_ratio_custom' action handler
-- should only be called if the user changed the apect ratio himself
-- (else the edit box containing the aspect ratio may not have been initiliazed here)
--if uiGrp ~= generalGrp then
--if uiGrp ~= generalGrp then
-- runAH(nil, 'game_config_change_screen_ratio_custom', '')
--end
uiGrp.active = true;
end
------------------------------------------------------------------------------------------------------------
--
--
function game:configInit()
-- init language
@ -187,9 +187,9 @@ function game:configInit()
winActive("wc_r2_dialogs", r2WinOn)
winActive("wc_r2_events", r2WinOn)
winActive("wc_r2_activities", r2WinOn)
winActive("wc_r2_feature_help", r2WinOn)
winActive("wc_r2_connect", not r2WinOn)
winActive("wc_r2_session_browser", not r2WinOn)
winActive("wc_r2_scenario_control", true)
winActive("wc_r2_feature_help", r2WinOn)
winActive("wc_r2_connect", not r2WinOn)
winActive("wc_r2_session_browser", not r2WinOn)
winActive("wc_r2_scenario_control", true)
winActive("wc_r2_player_tracking", r2WinOn)
end

View file

@ -61,8 +61,7 @@ void CAnimationFX::buildTrack(NL3D::UAnimationSet *as)
nlassert(Sheet != NULL);
if (!as) return;
if (Sheet->TrajectoryAnim.empty()) return;
std::string animName = Sheet->TrajectoryAnim;
NLMISC::strlwr(animName);
std::string animName = NLMISC::toLower(Sheet->TrajectoryAnim);
uint id = as->getAnimationIdByName(animName);
NL3D::UAnimation *anim = NULL;
if (id != NL3D::UAnimationSet::NotFound)

View file

@ -81,7 +81,7 @@ void initAutoAnimation()
file.getline(line, 512);
// Read the animation file
string animName = strlwr (CFile::getFilenameWithoutExtension(line));
string animName = toLower(CFile::getFilenameWithoutExtension(line));
uint id = AutoAnimSet->addAnimation (line, animName.c_str ());
if (id == UAnimationSet::NotFound)
{

View file

@ -610,7 +610,7 @@ uint32 CCharacterCL::buildEquipment(const CCharacterSheet::CEquipment &slot, SLO
{
// IS the item a valid one ?
CSheetId itemId;
if(itemId.buildSheetId(NLMISC::strlwr(slot.getItem())))
if(itemId.buildSheetId(NLMISC::toLower(slot.getItem())))
{
// Is it stored in the database ?
CEntitySheet *entitySheet = SheetMngr.get(itemId);
@ -1098,7 +1098,7 @@ string CCharacterCL::automatonType() const // virtual
//-----------------------------------------------
void CCharacterCL::computeAutomaton()
{
_CurrentAutomaton = automatonType() + "_" + NLMISC::strlwr(MBEHAV::modeToString(_Mode)) + ".automaton";
_CurrentAutomaton = automatonType() + "_" + NLMISC::toLower(MBEHAV::modeToString(_Mode)) + ".automaton";
}// computeAutomaton //

View file

@ -520,7 +520,7 @@ int main(int argc, char **argv)
uint i;
for (i=0; i<files.size(); i++)
{
if (strlwr (CFile::getExtension (files[i])) == "ttf")
if (toLower(CFile::getExtension (files[i])) == "ttf")
CFile::deleteFile (files[i]);
}
}

View file

@ -676,7 +676,6 @@ CClientConfig::CClientConfig()
DamageShieldEnabled = false;
AllowDebugLua = false;
LoadLuaDebugger = false;
DisplayLuaDebugInfo = false;
BeepWhenLaunched = false;
@ -1747,7 +1746,6 @@ void CClientConfig::setValues()
READ_BOOL_DEV(DamageShieldEnabled)
READ_BOOL_DEV(AllowDebugLua)
READ_BOOL_DEV(LoadLuaDebugger)
READ_BOOL_DEV(DisplayLuaDebugInfo)
READ_BOOL_DEV(LuaDebugInfoGotoButtonEnabled)

View file

@ -766,7 +766,6 @@ struct CClientConfig
/// Allow Lua commands (commands beginning with Lua)
bool AllowDebugLua;
bool LoadLuaDebugger;
bool LuaDebugInfoGotoButtonEnabled;
std::string LuaDebugInfoGotoButtonTemplate;

View file

@ -929,7 +929,7 @@ NLMISC_COMMAND(verbose, "Enable/Disable some Debug Information", "none or magic"
}
else
{
std::string type = NLMISC::strlwr(args[0]);
std::string type = NLMISC::toLower(args[0]);
if (type == "none")
Verbose = VerboseNone;
else if(type == "magic")

View file

@ -522,7 +522,7 @@ void CContinent::select(const CVectorD &pos, NLMISC::IProgressCallback &progress
// Associate IGs with the ZC number or -1 if there is no ZC.
for(uint i = 0; i<igsWithNames.size(); ++i)
{
string igZone = strlwr(CFile::getFilenameWithoutExtension(igsWithNames[i].second));
string igZone = toLower(CFile::getFilenameWithoutExtension(igsWithNames[i].second));
// Search for the IG name in the ZC list to associate.
for(uint j = 0; j<ZCList.size(); ++j)
@ -532,7 +532,7 @@ void CContinent::select(const CVectorD &pos, NLMISC::IProgressCallback &progress
if (outpost)
{
// If name matching -> this zone should be a ZC.
string outpostZone = strlwr(CFile::getFilenameWithoutExtension(ZCList[j].Name));
string outpostZone = toLower(CFile::getFilenameWithoutExtension(ZCList[j].Name));
if(igZone == outpostZone)
{
nlctassert(RZ_MAX_BUILDING_PER_OUTPOST==4);
@ -788,7 +788,7 @@ void CContinent::reloadFogMap()
const R2::CScenarioEntryPoints::CCompleteIsland *completeIsland = R2::CScenarioEntryPoints::getInstance().getCompleteIslandFromCoords(CVector2f((float) UserEntity->pos().x, (float) UserEntity->pos().y));
if (completeIsland)
{
std::string islandName = strlwr(completeIsland->Island);
std::string islandName = toLower(completeIsland->Island);
std::string::size_type lastPos = islandName.find_last_of("_");
if (lastPos != std::string::npos)
{

View file

@ -183,7 +183,7 @@ void CContinentManager::preloadSheets()
for (i = 0; i < ws->ContLocs.size(); ++i)
{
const SContLoc &clTmp = ws->ContLocs[i];
std::string continentSheetName = NLMISC::strlwr(clTmp.ContinentName);
std::string continentSheetName = NLMISC::toLower(clTmp.ContinentName);
if (continentSheetName.find(".continent") == std::string::npos)
{
continentSheetName += ".continent";

View file

@ -248,8 +248,7 @@ void CDoorManager::SDoor::checkToClose()
std::string CDoorManager::transformName (uint /* index */, const std::string &/* instanceName */, const std::string &shapeName)
{
if (shapeName.rfind('.') == string::npos) return shapeName;
string sExt = shapeName.substr(shapeName.rfind('.')+1,shapeName.size());
sExt = strlwr(sExt);
string sExt = toLower(shapeName.substr(shapeName.rfind('.')+1,shapeName.size()));
if (sExt != "pacs_prim") return shapeName;
return ""; // Do not load a pacs prim as a mesh...
}
@ -266,8 +265,7 @@ void CDoorManager::loadedCallback (NL3D::UInstanceGroup *ig)
string sShapeName = ig->getShapeName(k);
if (sShapeName.rfind('.') == string::npos) continue;
string sExt = sShapeName.substr(sShapeName.rfind('.')+1,sShapeName.size());
sExt = strlwr(sExt);
string sExt = toLower(sShapeName.substr(sShapeName.rfind('.')+1,sShapeName.size()));
if (sExt != "pacs_prim") continue;
// Check if the pacs_prim is a door detection
@ -349,7 +347,7 @@ void CDoorManager::loadedCallback (NL3D::UInstanceGroup *ig)
case SDoor::Matis3PartBourgeon:
{
string sDebug = ig->getShapeName(i);
sDebug = strlwr(sDebug.substr(sDebug.rfind('_')+1,sDebug.size()));
sDebug = toLower(sDebug.substr(sDebug.rfind('_')+1,sDebug.size()));
if (sDebug == "gauche")
pDoor->Instances[0] = i;
else if (sDebug == "droite")
@ -362,7 +360,7 @@ void CDoorManager::loadedCallback (NL3D::UInstanceGroup *ig)
case SDoor::Zorai2Part:
{
string sDebug = ig->getShapeName(i);
sDebug = strlwr(sDebug.substr(sDebug.rfind('_')+1,sDebug.size()));
sDebug = toLower(sDebug.substr(sDebug.rfind('_')+1,sDebug.size()));
if (sDebug == "gauche")
pDoor->Instances[0] = i;
else if (sDebug == "droite")

View file

@ -205,7 +205,7 @@ void CEntityAnimationManager::load(NLMISC::IProgressCallback &/* progress */, bo
for (uint32 i = 0; i < pASLS->AnimSetList.size(); ++i)
{
CAnimationSet as;
string sTmp = strlwr(pASLS->AnimSetList[i].Name);
string sTmp = toLower(pASLS->AnimSetList[i].Name);
sTmp = sTmp.substr(0,sTmp.rfind('.'));
pair<map<string,CAnimationSet>::iterator, bool> it;
it = _AnimSet.insert(pair<string,CAnimationSet>(sTmp,as));

View file

@ -520,7 +520,7 @@ void CGroundFXManager::update(const NLMISC::CVectorD &camPos)
}
if (!fxName.empty())
{
stdFXName = NLMISC::strlwr(NLMISC::CFile::getFilenameWithoutExtension(fxName));
stdFXName = NLMISC::toLower(NLMISC::CFile::getFilenameWithoutExtension(fxName));
}
// is an fx already attached to the entity ?
if (_SortedInstances[k]->HasFX)

View file

@ -197,7 +197,7 @@ void CIGCallback::CIGInstance::instanceGroupAdded()
uint numInstances = _IG->getNumInstance();
for(uint k = 0; k < numInstances; ++k)
{
TPacsPrimMap::iterator pbIt = PacsPrims.find(NLMISC::strlwr(NLMISC::CFile::getFilenameWithoutExtension(_IG->getShapeName(k))));
TPacsPrimMap::iterator pbIt = PacsPrims.find(NLMISC::toLower(NLMISC::CFile::getFilenameWithoutExtension(_IG->getShapeName(k))));
if (pbIt != PacsPrims.end())
{
// compute orientation and position

View file

@ -505,8 +505,7 @@ void checkDriverVersion()
uint i;
for (i=0; i< sizeofarray(driversVersion); i++)
{
string lwr = deviceName;
strlwr(lwr);
string lwr = toLower(deviceName);
if ((lwr.find (driversTest[i])!=string::npos) && (driversNTest[i]==NULL || lwr.find (driversNTest[i])==string::npos))
{
if (driverVersion < driversVersion[i])
@ -1290,7 +1289,7 @@ void initBotObjectSelection()
{
// IS the item a valid one ?
CSheetId itemId;
if(itemId.buildSheetId(NLMISC::strlwr(strShape)))
if(itemId.buildSheetId(NLMISC::toLower(strShape)))
{
// Get this item sheet ?
CItemSheet *itemSheet= dynamic_cast<CItemSheet *>(SheetMngr.get(itemId));

View file

@ -333,29 +333,29 @@ bool CCtrlSheetInfo::parseCtrlInfo(xmlNodePtr cur, CInterfaceGroup * /* parentGr
prop = (char*) xmlGetProp( cur, (xmlChar*)"nature" );
if (prop)
{
if (NLMISC::strlwr(prop.str()) == "item")
if (NLMISC::toLower(prop.str()) == "item")
_Type = CCtrlSheetInfo::SheetType_Item;
else if (NLMISC::strlwr(prop.str()) == "pact")
else if (NLMISC::toLower(prop.str()) == "pact")
_Type = CCtrlSheetInfo::SheetType_Pact;
else if (NLMISC::strlwr(prop.str()) == "skill")
else if (NLMISC::toLower(prop.str()) == "skill")
_Type = CCtrlSheetInfo::SheetType_Skill;
else if (NLMISC::strlwr(prop.str()) == "auto")
else if (NLMISC::toLower(prop.str()) == "auto")
_Type = CCtrlSheetInfo::SheetType_Auto;
else if (NLMISC::strlwr(prop.str()) == "macro")
else if (NLMISC::toLower(prop.str()) == "macro")
_Type = CCtrlSheetInfo::SheetType_Macro;
else if (NLMISC::strlwr(prop.str()) == "guild_flag")
else if (NLMISC::toLower(prop.str()) == "guild_flag")
_Type = CCtrlSheetInfo::SheetType_GuildFlag;
else if (NLMISC::strlwr(prop.str()) == "mission")
else if (NLMISC::toLower(prop.str()) == "mission")
_Type = CCtrlSheetInfo::SheetType_Mission;
else if (NLMISC::strlwr(prop.str()) == "sbrick")
else if (NLMISC::toLower(prop.str()) == "sbrick")
_Type = CCtrlSheetInfo::SheetType_SBrick;
else if (NLMISC::strlwr(prop.str()) == "sphraseid")
else if (NLMISC::toLower(prop.str()) == "sphraseid")
_Type = CCtrlSheetInfo::SheetType_SPhraseId;
else if (NLMISC::strlwr(prop.str()) == "sphrase")
else if (NLMISC::toLower(prop.str()) == "sphrase")
_Type = CCtrlSheetInfo::SheetType_SPhrase;
else if (NLMISC::strlwr(prop.str()) == "elevator_destination")
else if (NLMISC::toLower(prop.str()) == "elevator_destination")
_Type = CCtrlSheetInfo::SheetType_ElevatorDestination;
else if (NLMISC::strlwr(prop.str()) == "outpost_building")
else if (NLMISC::toLower(prop.str()) == "outpost_building")
_Type = CCtrlSheetInfo::SheetType_OutpostBuilding;
}
@ -363,8 +363,7 @@ bool CCtrlSheetInfo::parseCtrlInfo(xmlNodePtr cur, CInterfaceGroup * /* parentGr
prop = (char*) xmlGetProp( cur, (xmlChar*)"tx_noitem" );
if (prop)
{
string TxName = (const char *) prop;
TxName = strlwr (TxName);
string TxName = toLower((const char *) prop);
CViewRenderer &rVR = *CViewRenderer::getInstance();
_DispNoSheetBmpId = rVR.getTextureIdFromName (TxName);
}
@ -410,27 +409,23 @@ bool CCtrlSheetInfo::parseCtrlInfo(xmlNodePtr cur, CInterfaceGroup * /* parentGr
prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_l" );
if (prop)
{
string tmp = (const char *) prop;
_ListMenuLeft = strlwr(tmp);
_ListMenuLeft = toLower((const char *) prop);
}
prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_r" );
if (prop)
{
string tmp = (const char *) prop;
_ListMenuRight = strlwr(tmp);
_ListMenuRight = toLower((const char *) prop);
}
prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_r_empty_slot" );
if (prop)
{
string tmp = (const char *) prop;
_ListMenuRightEmptySlot = strlwr(tmp);
_ListMenuRightEmptySlot = toLower((const char *) prop);
}
// list menu on both clicks
prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_b" );
if (prop)
{
string tmp = (const char *) prop;
setListMenuBoth(strlwr(tmp));
setListMenuBoth(toLower((const char *) prop));
}
// _BrickTypeBitField
@ -1745,7 +1740,7 @@ void CDBCtrlSheet::resetCharBitmaps()
void CDBCtrlSheet::setupCharBitmaps(sint32 maxW, sint32 maxLine, sint32 maxWChar, bool topDown)
{
// Use the optString for the Macro name
_OptString = strlwr(_OptString);
_OptString = toLower(_OptString);
CInterfaceManager *pIM = CInterfaceManager::getInstance();
CViewRenderer &rVR = *CViewRenderer::getInstance();

View file

@ -74,7 +74,7 @@ void CCompassTarget::serial(NLMISC::IStream &f)
// for the name, try to save a string identifier if possible, because language may be changed between
// save & reload
f.serial(Name);
std::string language = strlwr(ClientCfg.LanguageCode);
std::string language = toLower(ClientCfg.LanguageCode);
f.serial(language);
f.serialEnum(_Type);
if (_Type == PosTracker)
@ -100,7 +100,7 @@ void CCompassTarget::serial(NLMISC::IStream &f)
// reset the compass to north to avoid incoherency
if (f.isReading())
{
if (strlwr(ClientCfg.LanguageCode) != language)
if (toLower(ClientCfg.LanguageCode) != language)
{
*this = CCompassTarget();
}

View file

@ -729,7 +729,7 @@ bool CDBGroupListAscensor::CSheetChildAscensor::isInvalidated(CDBGroupListSheetT
{
LIFT_ICONS::TLiftIcon li = (LIFT_ICONS::TLiftIcon)(icon & UINT64_CONSTANT(0x7FFFFFFFFFFFFFFF));
string str = strlwr(LIFT_ICONS::toString(li));
string str = toLower(LIFT_ICONS::toString(li));
Ctrl->setType(CCtrlSheetInfo::SheetType_Teleport_Location);
Ctrl->setSlot("asc_"+str+".tga");
}

View file

@ -294,7 +294,7 @@ bool CInterface3DScene::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
CXMLAutoPtr ptr((const char*)xmlGetProp (cur, (xmlChar*)"name"));
string animName;
if (ptr)
animName = strlwr (CFile::getFilenameWithoutExtension(ptr.str()));
animName = toLower(CFile::getFilenameWithoutExtension(ptr.str()));
if (!animName.empty())
{
@ -856,7 +856,7 @@ int CInterface3DCharacter::luaSetupCharacter3D(CLuaState &ls)
const char *funcName = "setupCharacter3D";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
setupCharacter3D((sint32) ls.toNumber(1));
setupCharacter3D((sint32) ls.toInteger(1));
return 0;
}
@ -1084,11 +1084,9 @@ bool CInterface3DIG::parse (xmlNodePtr cur, CInterface3DScene *parentGroup)
ptr = xmlGetProp (cur, (xmlChar*)"rot");
if (ptr) _Rot = convertVector(ptr);
string name;
ptr = xmlGetProp (cur, (xmlChar*)"name");
if (ptr) name = (const char*)ptr;
if (ptr) _Name = toLower((const char*)ptr);
_Name = strlwr(name);
_IG = UInstanceGroup::createInstanceGroup(_Name);
if (_IG == NULL)
return true; // Create anyway
@ -1202,7 +1200,7 @@ std::string CInterface3DIG::getName() const
// ----------------------------------------------------------------------------
void CInterface3DIG::setName (const std::string &ht)
{
string lwrname = strlwr(ht);
string lwrname = toLower(ht);
if (lwrname != _Name)
{
CInterface3DScene *pI3DS = dynamic_cast<CInterface3DScene*>(_Parent);
@ -1248,11 +1246,9 @@ bool CInterface3DShape::parse (xmlNodePtr cur, CInterface3DScene *parentGroup)
ptr = xmlGetProp (cur, (xmlChar*)"rot");
if (ptr) _Rot = convertVector(ptr);
string name;
ptr = xmlGetProp (cur, (xmlChar*)"name");
if (ptr) name = (const char*)ptr;
if (ptr) _Name = toLower((const char*)ptr);
_Name = strlwr(name);
_Instance = parentGroup->getScene()->createInstance(_Name);
if (_Instance.empty())
return false;
@ -1529,11 +1525,8 @@ bool CInterface3DFX::parse (xmlNodePtr cur, CInterface3DScene *parentGroup)
ptr = xmlGetProp (cur, (xmlChar*)"rot");
if (ptr) _Rot = convertVector(ptr);
string name;
ptr = xmlGetProp (cur, (xmlChar*)"name");
if (ptr) name = (const char*)ptr;
_Name = strlwr(name);
if (ptr) _Name = toLower((const char*)ptr);
return true;
}

View file

@ -2280,7 +2280,7 @@ void CInterfaceManager::displaySystemInfo(const ucstring &str, const string &cat
CRGBA color = CRGBA::White;
map<string, CClientConfig::SSysInfoParam>::const_iterator it = ClientCfg.SystemInfoParams.find(strlwr(cat));
map<string, CClientConfig::SSysInfoParam>::const_iterator it = ClientCfg.SystemInfoParams.find(toLower(cat));
if (it != ClientCfg.SystemInfoParams.end())
{
mode = it->second.Mode;
@ -2315,7 +2315,7 @@ void CInterfaceManager::displaySystemInfo(const ucstring &str, const string &cat
CRGBA CInterfaceManager::getSystemInfoColor(const std::string &cat)
{
CRGBA col = CRGBA::White;
map<string, CClientConfig::SSysInfoParam>::const_iterator it = ClientCfg.SystemInfoParams.find(strlwr(cat));
map<string, CClientConfig::SSysInfoParam>::const_iterator it = ClientCfg.SystemInfoParams.find(toLower(cat));
if (it != ClientCfg.SystemInfoParams.end())
col = it->second.Color;
return col;
@ -3327,11 +3327,17 @@ void CInterfaceManager::getLuaValueInfo(std::string &str, sint index)
sint type= ls.type(index);
if(type==LUA_TNIL)
{
str= "nil";
}
else if(type==LUA_TNUMBER)
str= NLMISC::toString(ls.toNumber(index));
{
str= NLMISC::toString(ls.isInteger(index) ? ls.toInteger(index):ls.toNumber(index));
}
else if(type==LUA_TBOOLEAN)
{
str= ls.toBoolean(index)?"true":"false";
}
else if(type==LUA_TSTRING)
{
ls.toString(index, str);

View file

@ -3488,7 +3488,7 @@ CItemImage &CInventoryManager::getServerItem(uint inv, uint index)
// ***************************************************************************
CInventoryManager::TInvType CInventoryManager::invTypeFromString(const string &str)
{
string sTmp = strlwr(str);
string sTmp = toLower(str);
if (sTmp == "inv_bag") return InvBag;
if (sTmp == "inv_pa0") return InvPA0;
if (sTmp == "inv_pa1") return InvPA1;

View file

@ -220,15 +220,22 @@ static DECLARE_INTERFACE_USER_FCT(lua)
}
else if(type==LUA_TNUMBER)
{
// get and pop
double val= ls.toNumber();
ls.pop();
// set double or integer?
if(val==floor(val))
result.setInteger(sint64(floor(val)));
if (ls.isInteger())
{
// get and pop
sint64 val= ls.toInteger();
ls.pop();
result.setInteger(val);
ok= true;
}
else
{
// get and pop
double val= ls.toNumber();
ls.pop();
result.setDouble(val);
ok= true;
ok= true;
}
}
else if(type==LUA_TSTRING)
{
@ -1020,7 +1027,7 @@ int CLuaIHMRyzom::setLuaBreakPoint(CLuaState &ls)
#ifdef LUA_NEVRAX_VERSION
if (LuaDebuggerIDE)
{
LuaDebuggerIDE->setBreakPoint(ls.toString(1), (int) ls.toNumber(2));
LuaDebuggerIDE->setBreakPoint(ls.toString(1), (int) ls.toInteger(2));
}
#endif
@ -1144,7 +1151,7 @@ int CLuaIHMRyzom::getPlayerDirection(CLuaState &ls)
int CLuaIHMRyzom::getPlayerGender(CLuaState &ls)
{
CLuaIHM::checkArgCount(ls, "getPlayerGender", 0);
ls.push((lua_Number)(UserEntity->getGender()));
ls.push((lua_Integer)(UserEntity->getGender()));
return 1;
}
@ -1210,7 +1217,7 @@ int CLuaIHMRyzom::getTargetGender(CLuaState &ls)
CLuaIHM::checkArgCount(ls, "getTargetGender", 0);
CCharacterCL* target = (CCharacterCL*)getTargetEntity();
if (!target) return (int)GSGENDER::unknown;
ls.push((lua_Number)(target->getGender()));
ls.push((lua_Integer)(target->getGender()));
return 1;
}
@ -1344,14 +1351,14 @@ int CLuaIHMRyzom::getSheet2idx(CLuaState &ls)
CLuaIHM::checkArgType(ls, "getSheet2idx", 2, LUA_TNUMBER);
const std::string & sheedtName = ls.toString(1);
uint32 slotId = (uint32)ls.toNumber(2);
uint32 slotId = (uint32)ls.toInteger(2);
NLMISC::CSheetId sheetId;
if (sheetId.buildSheetId(sheedtName))
{
uint32 idx = CVisualSlotManager::getInstance()->sheet2Index(sheetId, (SLOTTYPE::EVisualSlot)slotId);
ls.push((lua_Number)idx);
ls.push((lua_Integer)idx);
}
else
return 0;
@ -1362,7 +1369,7 @@ int CLuaIHMRyzom::getSheet2idx(CLuaState &ls)
int CLuaIHMRyzom::getTargetSlot(CLuaState &ls)
{
uint32 slot = (uint32)getTargetSlotNr();
ls.push((lua_Number)slot);
ls.push((lua_Integer)slot);
return 1;
}
@ -1372,7 +1379,7 @@ int CLuaIHMRyzom::getSlotDataSetId(CLuaState &ls)
CLuaIHM::checkArgCount(ls, "getSlotDataSetId", 1);
CLuaIHM::checkArgType(ls, "getSlotDataSetId", 1, LUA_TNUMBER);
uint32 slot = (uint32)ls.toNumber(1);
uint32 slot = (uint32)ls.toInteger(1);
CEntityCL *e = getSlotEntity(slot);
string id = toString(e->dataSetId());
ls.push(id);
@ -1676,7 +1683,7 @@ int CLuaIHMRyzom::displayBubble(CLuaState &ls)
strs.push_back(it.nextKey().toString());
}
InSceneBubbleManager.webIgChatOpen((uint32)ls.toNumber(1), ls.toString(2), strs, links);
InSceneBubbleManager.webIgChatOpen((uint32)ls.toInteger(1), ls.toString(2), strs, links);
return 1;
}

View file

@ -243,7 +243,7 @@ public:
while (*bufferPtr)
{
// Concat the directory name with the filename
if (strlwr (CFile::getExtension(bufferPtr)) == "m3u")
if (toLower(CFile::getExtension(bufferPtr)) == "m3u")
playlists.push_back (path+bufferPtr);
else
filenames.push_back (path+bufferPtr);

View file

@ -155,10 +155,10 @@ bool CPeopleList::create(const CPeopleListDesc &desc, const CChatWindowDesc *cha
//==================================================================
sint CPeopleList::getIndexFromName(const ucstring &name) const
{
string sNameIn = strlwr(name.toString());
string sNameIn = toLower(name.toString());
for(uint k = 0; k < _Peoples.size(); ++k)
{
string sPeopleName = strlwr(_Peoples[k].getName().toString());
string sPeopleName = toLower(_Peoples[k].getName().toString());
if (sPeopleName == sNameIn) return k;
}
return -1;

View file

@ -404,8 +404,7 @@ void CSBrickManager::compileBrickProperties()
string::size_type pos = prop.Text.find(':');
if (pos != string::npos)
{
string key = prop.Text.substr(0, pos);
strlwr(key);
string key = toLower(prop.Text.substr(0, pos));
string value = prop.Text.substr(pos + 1);
// get key id.
if (_BrickPropIdMap.find(key) == _BrickPropIdMap.end())
@ -501,12 +500,12 @@ void CSBrickManager::compileBrickProperties()
k++;
}
// get the key and replace text with value
if(key.size())
if (!key.empty())
{
// Parse all the brick properties if match the key
float value= 0.f;
// get the wanted prop id
strlwr(key);
key = toLower(key);
uint propId= getBrickPropId(key);
// if propid exist
if(propId)

View file

@ -59,8 +59,7 @@ bool CViewBitmapFaberMp::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup)
prop = (char*) xmlGetProp( cur, (xmlChar*)"tx_noitem" );
if (prop)
{
_TextureNoItemName = (const char *) prop;
_TextureNoItemName = strlwr (_TextureNoItemName);
_TextureNoItemName = toLower((const char *) prop);
_TextureNoItemId = -2;
}

View file

@ -95,8 +95,7 @@ bool CViewRadar::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup)
prop = (char*) xmlGetProp( cur, (xmlChar*)spotTextureNames[i] );
if (prop)
{
txName = (const char *) prop;
txName = strlwr (txName);
txName = toLower((const char *) prop);
}
_SpotDescriptions[i].TextureId.setTexture(txName.c_str());
rVR.getTextureSizeFromId (_SpotDescriptions[i].TextureId, _SpotDescriptions[i].TxW, _SpotDescriptions[i].TxH);
@ -105,8 +104,7 @@ bool CViewRadar::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup)
prop = (char*) xmlGetProp( cur, (xmlChar*)spotMiniTextureNames[i] );
if (prop)
{
txName = (const char *) prop;
txName = strlwr (txName);
txName = toLower((const char *) prop);
}
_SpotDescriptions[i].MiniTextureId.setTexture(txName.c_str());
rVR.getTextureSizeFromId (_SpotDescriptions[i].MiniTextureId, _SpotDescriptions[i].MTxW, _SpotDescriptions[i].MTxH);

View file

@ -108,7 +108,7 @@ void CMeshCameraColManager::instanceGroupAdded(NL3D::UInstanceGroup *ig)
bool avoidCollisionInside= ig->dontCastShadowForInterior(i);
bool avoidCollisionOutside= ig->dontCastShadowForExterior(i);
// very special patch for the matis serre (grrrrrrrrrrrrr)
avoidCollisionOutside= avoidCollisionOutside || strlwr(shapeName)== "ma_serre_interieur.shape";
avoidCollisionOutside= avoidCollisionOutside || toLower(shapeName)== "ma_serre_interieur.shape";
// then send the result to the collision manager, and keep the mesh col id if succeed
uint32 meshId= CollisionManager->addMeshInstanceCollision(colMesh, mat, avoidCollisionInside, avoidCollisionOutside);

View file

@ -692,7 +692,7 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c
if (!stringCategory.empty() && stringCategory != "SYS")
{
map<string, CClientConfig::SSysInfoParam>::const_iterator it;
it = ClientCfg.SystemInfoParams.find(strlwr(stringCategory));
it = ClientCfg.SystemInfoParams.find(toLower(stringCategory));
if (it != ClientCfg.SystemInfoParams.end())
{
col = it->second.Color;
@ -723,7 +723,7 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c
if( !stringCategory.empty() )
{
map<string, CClientConfig::SSysInfoParam>::const_iterator it;
it = ClientCfg.SystemInfoParams.find( strlwr(stringCategory) );
it = ClientCfg.SystemInfoParams.find( toLower(stringCategory) );
if( it != ClientCfg.SystemInfoParams.end() )
{
if( !(*it).second.SysInfoFxName.empty() )

View file

@ -99,7 +99,7 @@ void COutpost::initOutpost ()
for (i=0; i<RZ_MAX_BUILDING_PER_OUTPOST; i++)
{
// Put the ZC pacs_prim
TPacsPrimMap::iterator pbIt = PacsPrims.find(NLMISC::strlwr(NLMISC::CFile::getFilenameWithoutExtension(ClientCfg.ZCPacsPrim)));
TPacsPrimMap::iterator pbIt = PacsPrims.find(NLMISC::toLower(NLMISC::CFile::getFilenameWithoutExtension(ClientCfg.ZCPacsPrim)));
if (pbIt != PacsPrims.end())
{
// Build the building matrix

View file

@ -142,7 +142,7 @@ UInstanceGroup *getCluster(const UGlobalPosition &gp)
if(strPos.empty())
return 0;
// try to find the ig in the loaded ig map
std::map<std::string, UInstanceGroup *>::const_iterator igIt = IGLoaded.find(strlwr(strPos));
std::map<std::string, UInstanceGroup *>::const_iterator igIt = IGLoaded.find(toLower(strPos));
if (igIt != IGLoaded.end())
{
return igIt->second;
@ -188,7 +188,7 @@ void releaseLandscapeIGCallbacks()
void addPacsPrim(const std::string &fileName)
{
std::string ppName = NLMISC::strlwr(NLMISC::CFile::getFilenameWithoutExtension(fileName));
std::string ppName = NLMISC::toLower(NLMISC::CFile::getFilenameWithoutExtension(fileName));
if (PacsPrims.find(ppName) != PacsPrims.end())
{
nlwarning(("Pacs primitive " + ppName + " already has been inserted").c_str());

View file

@ -144,9 +144,9 @@ typedef CConfigVar<double> CConfigVarDouble;
inline std::string getConfigVarTypename(const sint32 &/* dummy */) { return "sint32"; }
inline bool getConfigVarValue(CLuaObject &luaValue, sint32 &dest)
{
if (luaValue.isNumber())
if (luaValue.isInteger())
{
dest = (sint32) luaValue.toNumber();
dest = (sint32) luaValue.toInteger();
return true;
}
return false;

View file

@ -403,10 +403,10 @@ sint CComLuaModule::luaSaveUserComponentFile(lua_State* state)
luaL_checktype(state, 1, LUA_TSTRING);
luaL_checktype(state, 2, LUA_TNUMBER);
std::string filename( lua_tostring(state, 1) );
double mustCompress( lua_tonumber(state, 2) );
bool mustCompress(lua_tointeger(state, 2) != 0);
CComLuaModule* this2 = getInstance(state);
this2->_Client->getEditionModule().saveUserComponentFile(filename, mustCompress != 0);
this2->_Client->getEditionModule().saveUserComponentFile(filename, mustCompress);
return 0;
}
@ -425,7 +425,7 @@ sint CComLuaModule::luaUpdateUserComponentsInfo(lua_State* state)
std::string filename( lua_tostring(state, 1) );
std::string name( lua_tostring(state, 2) );
std::string description( lua_tostring(state, 3) );
uint32 timestamp( static_cast<uint32>(lua_tonumber(state, 3) ));
uint32 timestamp( static_cast<uint32>(lua_tointeger(state, 3) ));
std::string md5Id( lua_tostring(state, 3) );
CComLuaModule* this2 = getInstance(state);
@ -441,7 +441,7 @@ sint CComLuaModule::luaGetSheetIdName(lua_State* state)
CComLuaModule* this2 = getInstance(state);
nlassert(this2);
uint32 sheetIdValue = static_cast<uint32>( lua_tonumber(state, 1) );
uint32 sheetIdValue = static_cast<uint32>( lua_tointeger(state, 1) );
NLMISC::CSheetId sheetId(sheetIdValue);
if(sheetId != NLMISC::CSheetId::Unknown)
@ -538,7 +538,7 @@ sint CComLuaModule::luaRequestSetWeather(lua_State* state)
{
//H_AUTO(R2_CComLuaModule_luaRequestSetWeather)
luaL_checktype(state, 1, LUA_TNUMBER);
uint16 weatherValue = (uint16) lua_tonumber(state, 1);
uint16 weatherValue = (uint16) lua_tointeger(state, 1);
CComLuaModule* this2 = getInstance(state);
nlassert(this2);
this2->_Client->getEditionModule().requestSetWeather(weatherValue);
@ -550,7 +550,7 @@ sint CComLuaModule::luaRequestSetSeason(lua_State* state)
{
//H_AUTO(R2_CComLuaModule_luaRequestSetSeason)
luaL_checktype(state, 1, LUA_TNUMBER);
uint8 season = (uint8) lua_tonumber(state, 1);
uint8 season = (uint8) lua_tointeger(state, 1);
CComLuaModule* this2 = getInstance(state);
nlassert(this2);
this2->_Client->getEditionModule().requestSetSeason(season);
@ -572,7 +572,7 @@ sint CComLuaModule::luaRequestStartAct(lua_State* state)
{
//H_AUTO(R2_CComLuaModule_luaRequestStartAct)
luaL_checktype(state, 1, LUA_TNUMBER);
uint32 actId(static_cast<uint32>(lua_tonumber(state, 1)));
uint32 actId(static_cast<uint32>(lua_tointeger(state, 1)));
CComLuaModule* this2 = getInstance(state);
nlassert(this2);
this2->_Client->getEditionModule().requestStartAct(actId);
@ -712,7 +712,7 @@ sint CComLuaModule::luaRequestMapConnection(lua_State* state)
CHECK_LUA_ARG_COUNT(1, "requestMapConnection");
luaL_checktype(state, 1, LUA_TNUMBER);
uint32 adventureId = static_cast<uint32>( lua_tonumber(state, 1) );
uint32 adventureId = static_cast<uint32>( lua_tointeger(state, 1) );
CComLuaModule* this2 = getInstance(state);
nlassert(this2);
@ -751,7 +751,7 @@ sint CComLuaModule::requestInsertNode(lua_State* state, bool isGhost)
std::string instanceId(lua_tostring(state, 1));
std::string attrName(lua_tostring(state, 2));
sint position(static_cast<sint>(lua_tonumber(state, 3)));
sint position(static_cast<sint>(lua_tointeger(state, 3)));
std::string key(lua_tostring(state, 4));
CObject* value = getObjectFromLua(state, 5);
value->setGhost(isGhost);
@ -837,7 +837,7 @@ sint CComLuaModule::luaRequestEraseNode(lua_State* state)
std::string attrName;
sint position = -1;
if (args>1){ attrName = lua_tostring(state, 2);}
if (args>2){ position = static_cast<sint>(lua_tonumber(state, 3));}
if (args>2){ position = static_cast<sint>(lua_tointeger(state, 3));}
CComLuaModule* this2 = getInstance(state);
nlassert(this2);
this2->_Client->requestEraseNode( instanceId, attrName, position);
@ -863,11 +863,11 @@ sint CComLuaModule::luaRequestMoveNode(lua_State* state)
std::string instanceId(lua_tostring(state, 1));
std::string attrName(lua_tostring(state, 2));
sint position = static_cast<sint>(lua_tonumber(state, 3));
sint position = static_cast<sint>(lua_tointeger(state, 3));
std::string instanceId2(lua_tostring(state, 4));
std::string attrName2(lua_tostring(state, 5));
sint position2 = static_cast<sint>(lua_tonumber(state, 6));
sint position2 = static_cast<sint>(lua_tointeger(state, 6));
CComLuaModule* this2 = getInstance(state);
nlassert(this2);
@ -967,7 +967,7 @@ sint CComLuaModule::luaRequestNewMultiAction(lua_State* state)
sint args = lua_gettop(state);
CHECK_LUA_ARG_COUNT(2, funcName);
luaL_checktype(state, 2, LUA_TNUMBER);
uint count = (uint) lua_tonumber(state, 2);
uint count = (uint) lua_tointeger(state, 2);
lua_pop(state, 1);
return luaRequestNewAction(state, false, count);
}
@ -979,7 +979,7 @@ sint CComLuaModule::luaRequestNewPendingMultiAction(lua_State* state)
sint args = lua_gettop(state);
CHECK_LUA_ARG_COUNT(2, funcName);
luaL_checktype(state, 2, LUA_TNUMBER);
uint count = (uint) lua_tonumber(state, 2);
uint count = (uint) lua_tointeger(state, 2);
lua_pop(state, 1);
return luaRequestNewAction(state, true, count);
}
@ -1049,6 +1049,13 @@ void CComLuaModule::setObjectToLua(lua_State* state, CObject* object)
lua_pushnil(state);
return;
}
if ( object->isInteger() )
{
lua_pushinteger(state, object->toInteger());
return;
}
if ( object->isNumber() )
{
lua_pushnumber(state, object->toNumber());
@ -1226,9 +1233,20 @@ CObject* CComLuaModule::getObjectFromLua(lua_State* state, sint idx)
{
case LUA_TNUMBER:
{
double value = lua_tonumber(state, -1);
lua_pop(state, 1);
return new CObjectNumber(value);
#if LUA_VERSION_NUM >= 503
if (lua_isinteger(state, -1) != 0)
{
sint64 value = lua_tointeger(state, -1);
lua_pop(state, 1);
return new CObjectInteger(value);
}
else
#endif
{
double value = lua_tonumber(state, -1);
lua_pop(state, 1);
return new CObjectNumber(value);
}
}
break;
@ -1738,8 +1756,8 @@ sint CComLuaModule::luaTriggerUserTrigger(lua_State* state)
//H_AUTO(R2_CComLuaModule_luaTriggerUserTrigger)
CComLuaModule* this2 = getInstance(state);
nlassert(this2);
uint32 actId( static_cast<uint32>(lua_tonumber(state, 1) ) );
uint32 id( static_cast<uint32>(lua_tonumber(state, 2) ));
uint32 actId( static_cast<uint32>(lua_tointeger(state, 1) ) );
uint32 id( static_cast<uint32>(lua_tointeger(state, 2) ));
this2->_Client->getEditionModule().requestTriggerUserTrigger(actId, id);
return 0;
@ -1869,7 +1887,7 @@ sint CComLuaModule::luaReserveIdRange(lua_State* state)
CHECK_LUA_ARG_COUNT(1, "reserveIdRange");
luaL_checktype(state, 1, LUA_TNUMBER);
uint32 range=static_cast<uint32>( lua_tonumber(state, 1) );
uint32 range=static_cast<uint32>( lua_tointeger(state, 1) );
this2->_Client->getEditionModule().reserveIdRange(range);
@ -1897,7 +1915,7 @@ sint CComLuaModule::luaRequestTpToEntryPoint(lua_State* state)
CHECK_LUA_ARG_COUNT(1, "requestTpToEntryPoint");
luaL_checktype(state, 1, LUA_TNUMBER);
uint32 actIndex = static_cast<uint32>( lua_tonumber(state, 1) );
uint32 actIndex = static_cast<uint32>( lua_tointeger(state, 1) );
this2->_Client->getEditionModule().requestTpToEntryPoint(actIndex);
return 0;
@ -1914,7 +1932,7 @@ sint CComLuaModule::luaRequestSetStartingAct(lua_State* state)
CHECK_LUA_ARG_COUNT(1, "requestSetStartingAct");
luaL_checktype(state, 1, LUA_TNUMBER);
uint32 actIndex = static_cast<uint32>( lua_tonumber(state, 1) );
uint32 actIndex = static_cast<uint32>( lua_tointeger(state, 1) );
this2->_Client->getEditionModule().requestSetStartingAct(actIndex);
return 0;
@ -1993,7 +2011,7 @@ sint CComLuaModule::luaSetDisplayInfo(lua_State* state)
std::string formName( lua_tostring(state, 1) );
bool displayInfo = static_cast<bool>(lua_tonumber(state, 2) == 0);
bool displayInfo = lua_tointeger(state, 2) != 0;
//this2->_Client->getEditionModule().reserveIdRange(range);
this2->_Client->getEditionModule().setDisplayInfo(formName, displayInfo);
@ -2024,7 +2042,7 @@ sint CComLuaModule::luaSetStartingActIndex(lua_State* state)
sint args = lua_gettop(state);
CHECK_LUA_ARG_COUNT(1, "setStartingActIndex");
luaL_checktype(state, 1, LUA_TNUMBER);
this2->_Client->getEditionModule().setStartingActIndex( static_cast<uint32>(lua_tonumber(state, 1)) );
this2->_Client->getEditionModule().setStartingActIndex( static_cast<uint32>(lua_tointeger(state, 1)) );
return 0;
}
@ -2229,12 +2247,12 @@ sint CComLuaModule::luaUpdateScenarioAck(lua_State* state)
{
std::string key = object->getKey(i);
CObject* value = object->getValue(i);
if (value->isNumber())
if (value->isInteger())
{
if (key.size() == 1)
{
level[key] = static_cast<int>(value->toNumber());
level[key] = static_cast<int>(value->toInteger());
}
}
}

View file

@ -46,6 +46,14 @@ double CPropertyAccessor::getValueAsNumber(CObject* component, const std::string
return object->toNumber();
}
sint64 CPropertyAccessor::getValueAsInteger(CObject* component, const std::string& attrName) const
{
//H_AUTO(R2_CPropertyAccessor_getValueAsInteger)
const CObject* object=getPropertyValue((const CObject *) component, attrName);
if (!object || !object->isInteger()) { return 0; }
return object->toInteger();
}
bool CPropertyAccessor::hasValueInBase(CObject *component, const std::string& attrName)
{
//H_AUTO(R2_CPropertyAccessor_hasValueInBase)

View file

@ -46,6 +46,7 @@ namespace R2
//get The propertyValue as number or 0 if not found
double getValueAsNumber(CObject* component, const std::string& attrName) const;
sint64 getValueAsInteger(CObject* component, const std::string& attrName) const;
const CObject* getPropertyValue(const CObject* component, const std::string& attrName) const;

View file

@ -1297,13 +1297,13 @@ int CEditor::luaSetPlotItemInfos(CLuaState &ls)
CLuaIHM::checkArgTypeUCString(ls, funcName, 3);
CLuaIHM::checkArgTypeUCString(ls, funcName, 4);
CLuaIHM::checkArgTypeUCString(ls, funcName, 5);
CItemSheet *item = dynamic_cast<CItemSheet *>(SheetMngr.get(CSheetId((uint32) ls.toNumber(2))));
CItemSheet *item = dynamic_cast<CItemSheet *>(SheetMngr.get(CSheetId((uint32) ls.toInteger(2))));
if (!item || item->Family != ITEMFAMILY::SCROLL_R2)
{
CLuaIHM::fails(ls, "%s : bad sheet, r2 plot item required", funcName);
}
R2::TMissionItem mi;
mi.SheetId = (uint32) ls.toNumber(2);
mi.SheetId = (uint32) ls.toInteger(2);
CLuaIHM::getUCStringOnStack(ls, 3, mi.Name);
CLuaIHM::getUCStringOnStack(ls, 4, mi.Description);
CLuaIHM::getUCStringOnStack(ls, 5, mi.Comment);
@ -1383,7 +1383,7 @@ int CEditor::luaKickCharacter(CLuaState &ls)
CSessionBrowserImpl &sb = CSessionBrowserImpl::getInstance();
sb.kickCharacter(sb.getCharId(), R2::getEditor().getDMC().getEditionModule().getCurrentAdventureId(),
(uint32)ls.toNumber(2));
(uint32)ls.toInteger(2));
if(!sb.waitOneMessage(sb.getMessageName("on_invokeResult")))
nlwarning("kickCharacter callback return false");
@ -1401,7 +1401,7 @@ int CEditor::luaUnkickCharacter(CLuaState &ls)
CSessionBrowserImpl &sb = CSessionBrowserImpl::getInstance();
sb.unkickCharacter(sb.getCharId(), R2::getEditor().getDMC().getEditionModule().getCurrentAdventureId(),
(uint32)ls.toNumber(2));
(uint32)ls.toInteger(2));
if(!sb.waitOneMessage(sb.getMessageName("on_invokeResult")))
nlwarning("unkickCharacter callback return false");
@ -1419,7 +1419,7 @@ int CEditor::luaTeleportToCharacter(CLuaState &ls)
CClientEditionModule & cem = R2::getEditor().getDMC().getEditionModule();
cem.requestTeleportOneCharacterToAnother(cem.getCurrentAdventureId(), CSessionBrowserImpl::getInstance().getCharId(),
(uint32)ls.toNumber(2));
(uint32)ls.toInteger(2));
return 0;
}
@ -1954,17 +1954,17 @@ int CEditor::luaRemoveInstanceObserver(CLuaState &ls)
const char *funcName = "removeInstanceObserver";
CLuaIHM::checkArgCount(ls, funcName, 2); // this is a method (self + 1 params)
CLuaIHM::checkArgType(ls, funcName, 2, LUA_TNUMBER); // instance id
IInstanceObserver *observer = getEditor().getInstanceObserver((TInstanceObserverHandle) ls.toNumber(2));
IInstanceObserver *observer = getEditor().getInstanceObserver((TInstanceObserverHandle) ls.toInteger(2));
if (observer == NULL)
{
CLuaIHM::fails(ls, "Instance observer not found for handle = %d", (int) ls.toNumber(2));
CLuaIHM::fails(ls, "Instance observer not found for handle = %d"NL_I64, ls.toInteger(2));
}
CInstanceObserverLua *luaObserver = dynamic_cast<CInstanceObserverLua *>(observer);
if (luaObserver == NULL)
{
CLuaIHM::fails(ls, "Instance observer found for handle %d, but has bad type, it wasn't registered from lua.", (int) ls.toNumber(2));
CLuaIHM::fails(ls, "Instance observer found for handle %d"NL_I64", but has bad type, it wasn't registered from lua.", ls.toInteger(2));
}
getEditor().removeInstanceObserver((TInstanceObserverHandle) ls.toNumber(2));
getEditor().removeInstanceObserver((TInstanceObserverHandle) ls.toInteger(2));
CLuaObject receiver = luaObserver->getReceiver();
delete luaObserver;
receiver.push();
@ -3221,10 +3221,10 @@ void CEditor::initObjectProjectionMetatable()
throw ELuaWrappedFunctionException(&ls, "Attempt to access an erased object");
}
if (ls.isNumber(2))
if (ls.isInteger(2))
{
// index is a number
const CObject *other = obj->getValue((uint32) ls.toNumber(2));
// index is an integer
const CObject *other = obj->getValue((uint32) ls.toInteger(2));
if (other)
{
pushValue(ls, other);
@ -3481,6 +3481,10 @@ void CEditor::initObjectProjectionMetatable()
{
ls.push(obj->toString());
}
else if (obj->isInteger())
{
ls.push(obj->toInteger());
}
else if (obj->isNumber())
{
ls.push(obj->toNumber());
@ -3574,9 +3578,9 @@ void CEditor::initObjectProjectionMetatable()
// continuation of traversal
// -> retrieve index from the key
sint32 index;
if (ls.isNumber(2))
if (ls.isInteger(2))
{
index = (uint32) ls.toNumber(2);
index = (uint32) ls.toInteger(2);
}
else
{
@ -5384,12 +5388,12 @@ sint CEditor::getLeftQuota()
CLuaState &ls = getLua();
CLuaStackChecker lsc(&ls);
callEnvMethod("getLeftQuota", 0, 1);
if (!ls.isNumber(-1))
if (!ls.isInteger(-1))
{
ls.pop(1);
return 0;
}
sint result = (sint) ls.toNumber(-1);
sint result = (sint) ls.toInteger(-1);
ls.pop(1);
return result;
}
@ -5419,7 +5423,7 @@ bool CEditor::verifyRoomLeft(uint aiCost, uint staticCost)
if (aiCost)
{
CLuaStackChecker lsc(&ls);
getEditor().getLua().push((lua_Number)aiCost);
getEditor().getLua().push((lua_Integer)aiCost);
callEnvMethod("checkAiQuota", 1, 1);
if (!ls.isBoolean(-1))
{
@ -5433,7 +5437,7 @@ bool CEditor::verifyRoomLeft(uint aiCost, uint staticCost)
if (staticCost)
{
CLuaStackChecker lsc(&ls);
getEditor().getLua().push((lua_Number)staticCost);
getEditor().getLua().push((lua_Integer)staticCost);
callEnvMethod("checkStaticQuota", 1, 1);
if (!ls.isBoolean(-1))
{
@ -5781,7 +5785,7 @@ void CEditor::scenarioUpdated(CObject* highLevel, bool willTP, uint32 initialAct
// teleport in good island
if (ClientCfg.Local)
{
sint locationId = (uint) _ScenarioInstance->getLuaProjection()["Description"]["LocationId"].toNumber();
sint locationId = (uint) _ScenarioInstance->getLuaProjection()["Description"]["LocationId"].toInteger();
CScenarioEntryPoints &sep = CScenarioEntryPoints::getInstance();
_IslandCollision.loadEntryPoints();
@ -6647,10 +6651,16 @@ std::string getString(const CObject *obj, const std::string &attrName)
double getNumber(const CObject *obj, const std::string &attrName)
{
obj = getObject(obj, attrName);
if (!obj) return 0;
return obj->isNumber() ? obj->toNumber() : 0;
if (!obj) return 0.0;
return obj->isNumber() ? obj->toNumber() : 0.0;
}
sint64 getInteger(const CObject *obj, const std::string &attrName)
{
obj = getObject(obj, attrName);
if (!obj) return 0;
return obj->isInteger() ? obj->toInteger() : 0;
}
bool isEditionCurrent()
{
@ -6703,7 +6713,7 @@ bool CEditor::getVisualPropertiesFromObject(CObject* object, SPropVisualA& vA, S
//-------------------------random init npc visual properties
std::map< std::string, double > visualProps;
std::map< std::string, sint64 > visualProps;
static const char* keys[] = { "GabaritHeight", "GabaritTorsoWidth", "GabaritArmsWidth", "GabaritLegsWidth", "GabaritBreastSize"
@ -6719,7 +6729,7 @@ bool CEditor::getVisualPropertiesFromObject(CObject* object, SPropVisualA& vA, S
unsigned int last = sizeof(keys) / sizeof(keys[0]);
for (; first != last; ++first)
{
visualProps[keys[first]] = getNumber(object, keys[first]);
visualProps[keys[first]] = getInteger(object, keys[first]);
}
//vA.PropertySubData.Sex = (uint) visualProps["Sex"];
@ -7054,10 +7064,10 @@ class CAHCreateEntity : public IActionHandler
if (getEditor().getEnv().callMethodByNameNoThrow("randomNPCProperties", 2, 1))
{
CLuaObject result(getEditor().getLua());
std::map< std::string, double > visualProps;
std::map< std::string, sint64 > visualProps;
ENUM_LUA_TABLE(result, it)
{
visualProps[it.nextKey().toString()] = it.nextValue().toNumber();
visualProps[it.nextKey().toString()] = it.nextValue().toInteger();
}
// visual property A depends on the type of the entity

View file

@ -650,9 +650,9 @@ sint CInstance::getSelectedSequence() const
//H_AUTO(R2_CInstance_getSelectedSequence)
CLuaObject selected = const_cast<CInstance *>(this)->getLuaProjection()["User"]["SelectedSequence"];
sint index = 0;
if (selected.isNumber())
if (selected.isInteger())
{
index = (sint) selected.toNumber();
index = (sint) selected.toInteger();
}
return index;
}

View file

@ -43,7 +43,7 @@ void readFromLua(const CLuaObject &table, const char *key, float &dest)
}
void readFromLua(const CLuaObject &table, const char *key, uint &dest)
{
if (table[key].isNumber()) dest = (uint) table[key].toNumber();
if (table[key].isInteger()) dest = (uint) table[key].toInteger();
}
void readFromLua(const CLuaObject &table, const char *key, std::string &dest)
{

View file

@ -66,17 +66,17 @@ bool CToolSelectMove::checkAdditionnalRoomLeftFor(CInstance &instance)
CLuaStackRestorer lsr(&ls, 0);
// check ai & static cost : if they are too big, can't create the duplicate
if (!luaProj.callMethodByNameNoThrow("getAiCost", 0, 1)
|| !ls.isNumber(-1))
|| !ls.isInteger(-1))
{
return false;
}
uint aiCost = (uint) ls.toNumber(-1);
uint aiCost = (uint) ls.toInteger(-1);
ls.pop();
if (!luaProj.callMethodByNameNoThrow("getStaticObjectCost", 0, 1))
{
return false;
}
uint staticCost = (uint) ls.toNumber(-1);
uint staticCost = (uint) ls.toInteger(-1);
ls.pop();
if (!getEditor().verifyRoomLeft(aiCost, staticCost))
{

View file

@ -659,7 +659,7 @@ void release()
CInterfaceExpr::release();
CPdrTokenRegistry::releaseInstance();
NLNET::IModuleManager::releaseInstance();
delete &CLuaManager::getInstance();
CLuaManager::releaseInstance();
NLGUI::CDBManager::release();
CWidgetManager::release();

View file

@ -194,7 +194,7 @@ int CSessionBrowserImpl::luaUpdateScenarioScores(CLuaState &ls)
if (R2::getEditor().getMode() != R2::CEditor::NotInitialized)
{
CSessionBrowserImpl::getInstance().setPlayerRating(getCharId(), R2::getEditor().getDMC().getEditionModule().getCurrentAdventureId(),
(uint32) ls.toNumber(1), (uint32) ls.toNumber(2), (uint32) ls.toNumber(3), (uint32) ls.toNumber(4), (uint32) ls.toNumber(5));
(uint32) ls.toInteger(1), (uint32) ls.toInteger(2), (uint32) ls.toInteger(3), (uint32) ls.toInteger(4), (uint32) ls.toInteger(5));
}
return 0;
@ -210,7 +210,7 @@ int CSessionBrowserImpl::luaJoinRingSession(CLuaState &ls)
CInterfaceManager *pIM = CInterfaceManager::getInstance();
CSessionBrowserImpl & sessionBrowser = CSessionBrowserImpl::getInstance();
sessionBrowser.joinSession(getCharId(), (TSessionId)(uint32) ls.toNumber(1), ClientCfg.ConfigFile.getVar("Application").asString(0));
sessionBrowser.joinSession(getCharId(), (TSessionId)(uint32) ls.toInteger(1), ClientCfg.ConfigFile.getVar("Application").asString(0));
if(!sessionBrowser.waitOneMessage(sessionBrowser.getMessageName("on_joinSessionResult")))
{

View file

@ -281,7 +281,7 @@ CBitmap *buildSharedBitmap(const std::string &filename,
{
alreadyBuilt = false;
if (filename.empty()) return NULL;
std::string lcBMFilename = strlwr(CFile::getFilenameWithoutExtension(filename));
std::string lcBMFilename = toLower(CFile::getFilenameWithoutExtension(filename));
std::map<std::string, CBitmap *>::iterator it = bitmapByName.find(lcBMFilename);
if (it != bitmapByName.end())
{

View file

@ -291,10 +291,8 @@ bool CStreamableIG::setIG(uint ig, const std::string &name, const std::string &p
}
// Load this IG
_IGs[ig].Name = NLMISC::CFile::getFilenameWithoutExtension(name);
_IGs[ig].ParentName = NLMISC::CFile::getFilenameWithoutExtension(parentName);
NLMISC::strlwr(_IGs[ig].Name);
NLMISC::strlwr(_IGs[ig].ParentName);
_IGs[ig].Name = NLMISC::toLower(NLMISC::CFile::getFilenameWithoutExtension(name));
_IGs[ig].ParentName = NLMISC::toLower(NLMISC::CFile::getFilenameWithoutExtension(parentName));
_IGs[ig].IG = NULL;
_IGs[ig].Loading = false;
_Linked = false;
@ -308,10 +306,8 @@ void CStreamableIG::addIG(const std::string &name,const std::string &parentName,
{
H_AUTO_USE(RZ_StremableIG)
_IGs.push_back(CIGNode ());
_IGs.back().Name = NLMISC::CFile::getFilenameWithoutExtension(name);
_IGs.back().ParentName = NLMISC::CFile::getFilenameWithoutExtension(parentName);
NLMISC::strlwr(_IGs.back().Name);
NLMISC::strlwr(_IGs.back().ParentName);
_IGs.back().Name = NLMISC::toLower(NLMISC::CFile::getFilenameWithoutExtension(name));
_IGs.back().ParentName = NLMISC::toLower(NLMISC::CFile::getFilenameWithoutExtension(parentName));
_IGs.back().IG = NULL;
_IGs.back().Loading = false;
_IGs.back().Pos = pos;
@ -376,7 +372,7 @@ void CStreamableIG::addLoadedIGToMap()
if (_IGs[k].IG && _IGs[k].IG != (NL3D::UInstanceGroup *)-1) // is this a successfully loaded ig ?
{
// insert the new ig if it hasn't before..
if( _IGMap->insert(std::make_pair(NLMISC::strlwr(_IGs[k].Name), _IGs[k].IG)).second )
if( _IGMap->insert(std::make_pair(NLMISC::toLower(_IGs[k].Name), _IGs[k].IG)).second )
// if inserted, must notify IG Added, else already notifiyed by loadAsync()
this->notifyIGAdded(_IGs[k].IG);
}

View file

@ -1413,8 +1413,7 @@ const ucchar * CStringManagerClient::getSpecialWord(const std::string &label, bo
// avoid case problems
static std::string lwrLabel;
lwrLabel = label;
strlwr(lwrLabel);
lwrLabel = toLower(label);
if (_SpecItem_MemoryCompressed)
{
@ -1464,8 +1463,7 @@ const ucchar * CStringManagerClient::getSpecialDesc(const std::string &label)
// avoid case problems
static std::string lwrLabel;
lwrLabel= label;
strlwr(lwrLabel);
lwrLabel = toLower(label);
if (_SpecItem_MemoryCompressed)
{
@ -1498,8 +1496,7 @@ const ucchar * CStringManagerClient::getSpecialDesc2(const std::string &label)
// avoid case problems
static std::string lwrLabel;
lwrLabel= label;
strlwr(lwrLabel);
lwrLabel = toLower(label);
if (_SpecItem_MemoryCompressed)
{
@ -1703,8 +1700,7 @@ void CStringManagerClient::replaceSBrickName(NLMISC::CSheetId id, const ucstring
// avoid case problems
static std::string lwrLabel;
lwrLabel= label;
strlwr(lwrLabel);
lwrLabel = toLower(label);
if (_SpecItem_MemoryCompressed)
{

View file

@ -359,8 +359,7 @@ void CStaticFames::loadStaticFame( const string& filename )
// 1st, build the index table
for (uint i=1; i<ws.size(); ++i)
{
string name = ws.getData(i, 0).toString();
name = strlwr(name);
string name = toLower(ws.getData(i, 0).toString());
if (name.empty())
break;
_FactionNameIndex.insert(make_pair(CStringMapper::map(name), i-1));
@ -376,8 +375,7 @@ void CStaticFames::loadStaticFame( const string& filename )
// 2nd check the table structure
for (uint i=2; i<ws.ColCount; ++i)
{
string name = ws.getData(0, i).toString();
name = strlwr(name);
string name = toLower(ws.getData(0, i).toString());
if (name.empty())
{
@ -608,8 +606,7 @@ uint CStaticFames::getFactionIndex(NLMISC::TStringId factionName)
//----------------------------------------------------------------------------
uint CStaticFames::getFactionIndex(const std::string &factionName)
{
string n = strlwr(factionName);
return getFactionIndex(CStringMapper::map(n));
return getFactionIndex(CStringMapper::map(toLower(factionName)));
}
//----------------------------------------------------------------------------
@ -667,11 +664,7 @@ sint32 CStaticFames::getStaticFame(NLMISC::TStringId faction1, NLMISC::TStringId
//----------------------------------------------------------------------------
sint32 CStaticFames::getStaticFame(const std::string &faction1, const std::string &faction2)
{
string n1, n2;
n1 = strlwr(faction1);
n2 = strlwr(faction2);
return getStaticFame(CStringMapper::map(n1), CStringMapper::map(n2));
return getStaticFame(CStringMapper::map(toLower(faction1)), CStringMapper::map(toLower(faction2)));
}
//----------------------------------------------------------------------------

View file

@ -168,6 +168,12 @@ void CObject::inPlaceCopy(const CObjectNumber &src)
copyMismatchMsg(src);
}
void CObject::inPlaceCopy(const CObjectInteger &src)
{
//H_AUTO(R2_CObject_inPlaceCopy)
copyMismatchMsg(src);
}
void CObject::inPlaceCopy(const CObjectTable &src)
{
//H_AUTO(R2_CObject_inPlaceCopy)
@ -189,6 +195,18 @@ bool CObject::isNumber(const std::string & prop) const
return doIsNumber();
}
bool CObject::isInteger(const std::string & prop) const
{
//H_AUTO(R2_CObject_isInteger)
if (!prop.empty())
{
CObject* attr = getAttr(prop);
if (!attr) return false;
return attr->doIsInteger();
}
return doIsInteger();
}
bool CObject::isString(const std::string & prop) const
{
//H_AUTO(R2_CObject_isString)
@ -239,6 +257,12 @@ bool CObject::doIsNumber() const
return false;
}
bool CObject::doIsInteger() const
{
//H_AUTO(R2_CObject_doIsInteger)
return false;
}
bool CObject::doIsString() const
{
//H_AUTO(R2_CObject_doIsString)
@ -272,6 +296,20 @@ double CObject::toNumber(const std::string & prop) const
return doToNumber();
}
sint64 CObject::toInteger(const std::string & prop) const
{
//H_AUTO(R2_CObject_toInteger)
if (!prop.empty())
{
CObject* attr = getAttr(prop);
if (!attr)
{
BOMB("Try to use the method toInteger() on a NULL Object", return 0);
}
return attr->doToInteger();
}
return doToInteger();
}
std::string CObject::toString(const std::string & prop) const
{
@ -328,6 +366,14 @@ double CObject::doToNumber() const
}
sint64 CObject::doToInteger() const
{
//H_AUTO(R2_CObject_doToInteger)
BOMB("Try to convert an objet to integer without being allowed", return 0);
return 0;
}
std::string CObject::doToString() const
{
//H_AUTO(R2_CObject_doToString)
@ -366,11 +412,18 @@ bool CObject::set(const std::string& /* key */, const std::string & /* value */)
return false;
}
bool CObject::set(const std::string& /* key */, double /* value */){
bool CObject::set(const std::string& /* key */, double /* value */)
{
BOMB("Try to set the value of an object with a double on an object that does not allowed it", return false);
return false;
}
bool CObject::set(const std::string& /* key */, sint64 /* value */)
{
BOMB("Try to set the value of an object with an integer on an object that does not allowed it", return false);
return false;
}
bool CObject::setObject(const std::string& /* key */, CObject* /* value */)
{
BOMB("Try to set the value of an object with an object that does not allowed it", return false);
@ -602,7 +655,7 @@ bool CObjectString::set(const std::string& key, const std::string & value)
bool CObjectString::setObject(const std::string& key, CObject* value)
{
//H_AUTO(R2_CObjectString_setObject)
BOMB_IF( !key.empty() || ! (value->isString() || value->isNumber()) , "Try to set the a sub value of an object that does not allowed it", return false);
BOMB_IF( !key.empty() || ! (value->isString() || value->isNumber() || value->isInteger()) , "Try to set the a sub value of an object that does not allowed it", return false);
bool canSet = set(key, value->toString());
if (canSet)
{
@ -732,7 +785,7 @@ void CObjectNumber::inPlaceCopy(const CObjectNumber &src)
}
std::string CObjectNumber::doToString() const { return NLMISC::toString("%d", _Value);}
std::string CObjectNumber::doToString() const { return NLMISC::toString("%lf", _Value);}
void CObjectNumber::doSerialize(std::string& out, CSerializeContext& /* context */) const
{
@ -767,9 +820,6 @@ bool CObjectNumber::set(const std::string& key, const std::string & value)
//H_AUTO(R2_CObjectNumber_set)
//XXX
BOMB_IF(key != "", "Try to set an element of a table on an object that is not a table", return false);
// std::stringstream ss ;
// ss << value;
// ss >> _Value;
NLMISC::fromString(value, _Value);
return true;
}
@ -808,12 +858,108 @@ bool CObjectNumber::equal(const CObject* other) const
double otherValue = other->toNumber();
if (_Value == otherValue ) return true;
/*
fabs + epsilon trick
TODO: fabs + epsilon trick
*/
return false;
}
//----------------------- CObjectInteger ----------------------------------------
CObjectInteger::CObjectInteger(sint64 value) : CObject(), _Value(value){}
const char *CObjectInteger::getTypeAsString() const
{
return "Integer";
}
void CObjectInteger::visitInternal(IObjectVisitor &visitor)
{
//H_AUTO(R2_CObjectInteger_visit)
visitor.visit(*this);
}
void CObjectInteger::inPlaceCopyTo(CObject &dest) const
{
//H_AUTO(R2_CObjectInteger_inPlaceCopyTo)
dest.inPlaceCopy(*this);
}
void CObjectInteger::inPlaceCopy(const CObjectInteger &src)
{
//H_AUTO(R2_CObjectInteger_inPlaceCopy)
_Value = src._Value;
setGhost(src.getGhost());
}
std::string CObjectInteger::doToString() const { return NLMISC::toString("%d"NL_I64, _Value); }
void CObjectInteger::doSerialize(std::string& out, CSerializeContext& /* context */) const
{
//H_AUTO(R2_CObjectInteger_doSerialize)
nlassert(!getGhost());
out += NLMISC::toString(_Value);
}
bool CObjectInteger::set(const std::string& key, sint64 value)
{
//H_AUTO(R2_CObjectInteger_set)
BOMB_IF(key != "", "Try to set an element of a table on an object that is not a table", return false);
_Value = value;
return true;
}
bool CObjectInteger::set(const std::string& key, const std::string & value)
{
//H_AUTO(R2_CObjectInteger_set)
//XXX
BOMB_IF(key != "", "Try to set an element of a table on an object that is not a table", return false);
NLMISC::fromString(value, _Value);
return true;
}
sint64 CObjectInteger::doToInteger() const { return _Value; }
CObject* CObjectInteger::clone() const
{
//H_AUTO(R2_CObjectInteger_clone)
CObjectInteger *result = new CObjectInteger(_Value);
result->setGhost(getGhost());
return result;
}
bool CObjectInteger::doIsInteger() const { return true;}
bool CObjectInteger::setObject(const std::string& /* key */, CObject* value)
{
//H_AUTO(R2_CObjectInteger_setObject)
BOMB_IF(!value->isInteger(), NLMISC::toString("Try to set an element of a type '%s' with a value of type '%s' on an object that is not an integer", this->getTypeAsString(), value->getTypeAsString()), return false);
_Value = value->toInteger();
setGhost(value->getGhost());
return true;
}
bool CObjectInteger::equal(const CObject* other) const
{
//H_AUTO(R2_CObjectInteger_equal)
if (!other || !other->isInteger()) return false;
sint64 otherValue = other->toInteger();
return _Value == otherValue;
}
//----------------------- CObjectTable ----------------------------------------
@ -1756,7 +1902,7 @@ CObject* CObjectGenerator::instanciate(CObjectFactory* factory) const
{
CObject*defaultInBase = found->getAttr("DefaultInBase");
if (!defaultInBase || (defaultInBase->isNumber() && defaultInBase->toNumber() != 1))
if (!defaultInBase || (defaultInBase->isInteger() && defaultInBase->toInteger() != 1))
{
std::string type = found->toString("Type");
@ -1824,7 +1970,15 @@ void CObjectNumber::dump(const std::string prefix, uint depth) const
{
//H_AUTO(R2_CObjectNumber_dump)
std::string result(depth * 4, ' ');
result += NLMISC::toString("%sNumber, ptr = 0x%p, value = %f, ghost = %s", prefix.c_str(), this, _Value, _Ghost ? "true" : "false");
result += NLMISC::toString("%sNumber, ptr = 0x%p, value = %lf, ghost = %s", prefix.c_str(), this, _Value, _Ghost ? "true" : "false");
nlwarning(result.c_str());
}
void CObjectInteger::dump(const std::string prefix, uint depth) const
{
//H_AUTO(R2_CObjectInteger_dump)
std::string result(depth * 4, ' ');
result += NLMISC::toString("%sInteger, ptr = 0x%p, value = %d"NL_I64", ghost = %s", prefix.c_str(), this, _Value, _Ghost ? "true" : "false");
nlwarning(result.c_str());
}
@ -1929,96 +2083,169 @@ std::string CObject::uint32ToInstanceId(uint32 id)
static void writeNumber( NLMISC::IStream& stream, double theValue)
{
double value = theValue;
double absValue = fabs(value);
uint8 type;
double value = theValue;
double absValue = fabs(value);
uint8 type;
// It's 0
if (absValue <= std::numeric_limits<double>::epsilon())
// It's 0
if (absValue <= std::numeric_limits<double>::epsilon())
{
type = ObjectNumberZero;
stream.serial(type);
return;
}
double integral;
double fractional = modf(absValue, &integral);
// It is an integral type (no fractional part)
if ( fractional <= std::numeric_limits<double>::epsilon() )
{
bool pos = 0.0 <= value;
// positif
if (pos)
{
type = ObjectNumberZero;
if (integral <= uint8Max)
{
uint8 uint8value = static_cast<uint8>(value);
type = ObjectNumberUInt8;
stream.serial(type);
stream.serial( uint8value);
return;
}
if (integral <= uint16Max)
{
uint16 uint16value = static_cast<uint16>(value);
type = ObjectNumberUInt16;
stream.serial(type);
stream.serial(uint16value);
return;
}
if (integral <= uint32Max)
{
uint32 uint32value = static_cast<uint32>(value);
type = ObjectNumberUInt32;
stream.serial(type);
stream.serial(uint32value);
return;
}
}
//negatif
else
{
if ( sint8Min <= integral && integral <= sint8Max)
{
sint8 sint8value = static_cast<sint8>(value);
type = ObjectNumberSInt8;
stream.serial(type);
stream.serial( sint8value);
return;
}
if ( sint16Min <= integral && integral <= sint16Max)
{
sint16 sint16value = static_cast<sint16>(value);
type = ObjectNumberSInt16;
stream.serial(type);
stream.serial( sint16value);
return;
}
if ( sint32Min <= integral && integral <= sint32Max)
{
sint32 sint32value = static_cast<sint32>(value);
type = ObjectNumberSInt32;
stream.serial(type);
stream.serial( sint32value);
return;
}
}
}
//Default case
// Float are evil: you loose too much precision
type = ObjectNumberDouble;
double fValue = value;
stream.serial(type);
stream.serial(fValue);
}
static void writeInteger( NLMISC::IStream& stream, sint64 theValue)
{
sint64 value = theValue;
uint8 type;
// It's 0
if (value == 0)
{
type = ObjectNumberZero;
stream.serial(type);
return;
}
bool pos = value >= 0;
// positif
if (pos)
{
if (value <= uint8Max)
{
uint8 uint8value = static_cast<uint8>(value);
type = ObjectNumberUInt8;
stream.serial(type);
stream.serial( uint8value);
return;
}
double integral;
double fractional = modf(absValue, &integral);
// It is an integral type (no fractional part)
if ( fractional <= std::numeric_limits<double>::epsilon() )
if (value <= uint16Max)
{
bool pos = 0.0 <= value;
// positif
if (pos)
{
if (integral <= uint8Max)
{
uint8 uint8value = static_cast<uint8>(value);
type = ObjectNumberUInt8;
stream.serial(type);
stream.serial( uint8value);
return;
}
if (integral <= uint16Max)
{
uint16 uint16value = static_cast<uint16>(value);
type = ObjectNumberUInt16;
stream.serial(type);
stream.serial(uint16value);
return;
}
if (integral <= uint32Max)
{
uint32 uint32value = static_cast<uint32>(value);
type = ObjectNumberUInt32;
stream.serial(type);
stream.serial(uint32value);
return;
}
}
//negatif
else
{
if ( sint8Min <= integral && integral <= sint8Max)
{
sint8 sint8value = static_cast<sint8>(value);
type = ObjectNumberSInt8;
stream.serial(type);
stream.serial( sint8value);
return;
}
if ( sint16Min <= integral && integral <= sint16Max)
{
sint16 sint16value = static_cast<sint16>(value);
type = ObjectNumberSInt16;
stream.serial(type);
stream.serial( sint16value);
return;
}
if ( sint32Min <= integral && integral <= sint32Max)
{
sint32 sint32value = static_cast<sint32>(value);
type = ObjectNumberSInt32;
stream.serial(type);
stream.serial( sint32value);
return;
}
}
uint16 uint16value = static_cast<uint16>(value);
type = ObjectNumberUInt16;
stream.serial(type);
stream.serial(uint16value);
return;
}
//Default case
// Float are evil: you loose too much precision
type = ObjectNumberDouble;
double fValue = value;
stream.serial(type);
stream.serial(fValue);
if (value <= uint32Max)
{
uint32 uint32value = static_cast<uint32>(value);
type = ObjectNumberUInt32;
stream.serial(type);
stream.serial(uint32value);
return;
}
}
//negatif
else
{
if ( sint8Min <= value && value <= sint8Max)
{
sint8 sint8value = static_cast<sint8>(value);
type = ObjectNumberSInt8;
stream.serial(type);
stream.serial( sint8value);
return;
}
if ( sint16Min <= value && value <= sint16Max)
{
sint16 sint16value = static_cast<sint16>(value);
type = ObjectNumberSInt16;
stream.serial(type);
stream.serial( sint16value);
return;
}
}
// Default case
type = ObjectNumberSInt32;
sint32 fValue = (sint32)value;
stream.serial(type);
stream.serial(fValue);
}
static void serialStringInstanceId( NLMISC::IStream& stream, CObject*& data)
@ -2940,6 +3167,13 @@ void CObjectSerializerImpl::serialImpl(NLMISC::IStream& stream, CObject*& data,
uint endLength = stream.getPos();
if (serializer->Log) { nldebug("R2NET: (%u) Null sent %u bytes", serializer->Level, endLength - initLength);}
}
else if (data->isInteger())
{
uint initLength = stream.getPos();
writeInteger(stream, data->toInteger());
uint endLength = stream.getPos();
if (serializer->Log) { nldebug("R2NET: (%u) Integer sent %u bytes", serializer->Level, endLength - initLength); }
}
else if (data->isNumber())
{
uint initLength = stream.getPos();

View file

@ -38,6 +38,7 @@ class CObjectTable;
class CObjectString;
class CObjectRefId;
class CObjectNumber;
class CObjectInteger;
class CSerializeContext;
@ -49,6 +50,7 @@ struct IObjectVisitor
virtual void visit(CObjectRefId &/* obj */) {}
virtual void visit(CObjectString &/* obj */) {}
virtual void visit(CObjectNumber &/* obj */) {}
virtual void visit(CObjectInteger &/* obj */) {}
virtual void visit(CObjectTable &/* obj */) {}
};
@ -82,6 +84,8 @@ public:
// test type
bool isNumber(const std::string & prop="") const;
bool isInteger(const std::string & prop="") const;
bool isString(const std::string & prop="") const;
bool isTable(const std::string & prop="") const;
@ -93,6 +97,8 @@ public:
// to Value
double toNumber(const std::string & prop="") const;
sint64 toInteger(const std::string & prop="") const;
std::string toString(const std::string & prop="") const;
CObjectTable* toTable(const std::string & prop="") const;
@ -127,12 +133,16 @@ public:
void add(const std::string& key, double value);
void add(const std::string& key, sint64 value);
// set Value
virtual bool set(const std::string& key, const std::string & value);
virtual bool set(const std::string& key, double value);
virtual bool set(const std::string& key, sint64 value);
virtual bool setObject(const std::string& key, CObject* value);
CObject* getParent() const;
@ -172,6 +182,8 @@ protected:
virtual bool doIsNumber() const;
virtual bool doIsInteger() const;
virtual bool doIsString() const;
virtual bool doIsTable() const;
@ -180,6 +192,8 @@ protected:
virtual double doToNumber() const;
virtual sint64 doToInteger() const;
virtual std::string doToString() const;
virtual CObjectTable* doToTable() const;
@ -192,6 +206,7 @@ public:
virtual void inPlaceCopyTo(CObject &dest) const = 0;
virtual void inPlaceCopy(const CObjectString &src);
virtual void inPlaceCopy(const CObjectNumber &src);
virtual void inPlaceCopy(const CObjectInteger &src);
virtual void inPlaceCopy(const CObjectTable &src);
protected:
void copyMismatchMsg(const CObject &src);
@ -307,6 +322,45 @@ private:
};
class CObjectInteger : public CObject
{
public:
explicit CObjectInteger(sint64 value);
virtual const char *getTypeAsString() const;
virtual bool set(const std::string& key, sint64 value);
virtual bool set(const std::string& key, const std::string &value);
virtual bool setObject(const std::string& key, CObject* value);
virtual CObject* clone() const;
sint64 getValue() const { return _Value; }
virtual void dump(const std::string prefix = "", uint depth = 0) const;
virtual bool equal(const CObject* other) const;
protected:
virtual void doSerialize(std::string& out, CSerializeContext& context) const;
virtual bool doIsInteger() const;
virtual sint64 doToInteger() const;
virtual std::string doToString() const;
virtual void inPlaceCopyTo(CObject &dest) const;
virtual void inPlaceCopy(const CObjectInteger &src);
virtual void visitInternal(IObjectVisitor &visitor);
private:
sint64 _Value;
};
class CObjectTable: public CObject
{

View file

@ -609,9 +609,9 @@ public:
void setAttributeAsBool(const std::string & attrName, const std::string& propName)
{
CObject* attr = _Object->getAttr(attrName);
if (attr && attr->isNumber())
if (attr && attr->isInteger())
{
sint value = static_cast<sint>(attr->toNumber());
sint value = static_cast<sint>(attr->toInteger());
_Primitive->addPropertyByName(propName.c_str(), new CPropertyString(value?"true":"false"));
}
}
@ -1093,7 +1093,7 @@ IPrimitive* CServerAnimationModule::getAction(CObject* action, const std::string
CObject* weight = action->getAttr("Weight");
if(weight)
{
uint32 w = (int)weight->toNumber();
uint32 w = (int)weight->toInteger();
std::string weightStr = toString(w);
pAction->addPropertyByName("Weight", new CPropertyString(weightStr));
}
@ -1381,7 +1381,7 @@ bool CServerAnimationModule::translateActToPrimitive(CInstanceMap& components, C
animSession->Acts[actId] = rtAct;
if ( act->isNumber("LocationId")
if ( act->isInteger("LocationId")
&& act->isString("Name")
&& act->isString("ActDescription")
&& act->isString("PreActDescription")
@ -1390,7 +1390,7 @@ bool CServerAnimationModule::translateActToPrimitive(CInstanceMap& components, C
rtAct->Name = act->toString("Name");
rtAct->ActDescription = act->toString("ActDescription");
rtAct->PreActDescription = act->toString("PreActDescription");
rtAct->LocationId = static_cast<uint32>(act->toNumber("LocationId"));
rtAct->LocationId = static_cast<uint32>(act->toInteger("LocationId"));
}
else
{
@ -1508,9 +1508,9 @@ bool CServerAnimationModule::translateActToPrimitive(CInstanceMap& components, C
a2pAiState.setAttributeAsStringArray("Keywords", "keywords");
bool isTriggerZone = false;
if ( aiState->isNumber("IsTriggerZone") )
if ( aiState->isInteger("IsTriggerZone") )
{
isTriggerZone = static_cast<uint32>(aiState->toNumber("IsTriggerZone")) == 1;
isTriggerZone = aiState->toInteger("IsTriggerZone") == 1;
}
if (isTriggerZone)
{
@ -1550,7 +1550,7 @@ bool CServerAnimationModule::translateActToPrimitive(CInstanceMap& components, C
npc_group->addPropertyByName("name", new CPropertyString(prefix+component->toString("Id")));
npc_group->addPropertyByName("ai_type", new CPropertyString("GROUP_NPC")); // AJM
if (component->isNumber("AutoSpawn") && component->toNumber("AutoSpawn")==0)
if (component->isInteger("AutoSpawn") && component->toInteger("AutoSpawn")==0)
{
npc_group->addPropertyByName("autoSpawn", new CPropertyString("false"));
}
@ -1740,9 +1740,9 @@ bool CServerAnimationModule::translateActToPrimitive(CInstanceMap& components, C
npc_bot->insertChild(npc_bot_alias);
// nlinfo("R2Anim: Bot %u %s", npc_bot_alias->getFullAlias(), std::string(prefix+objectNpc->toString("Id")).c_str());
uint32 dmProperty = 0;
if (objectNpc->isNumber("DmProperty"))
if (objectNpc->isInteger("DmProperty"))
{
dmProperty = static_cast< uint32 > (objectNpc->toNumber("DmProperty"));
dmProperty = static_cast< uint32 > (objectNpc->toInteger("DmProperty"));
}
CRtNpc* rtNpc = new CRtNpc(npc_bot_alias->getFullAlias(), objectNpc, npc_group_alias->getFullAlias(), dmProperty);
@ -1770,9 +1770,9 @@ bool CServerAnimationModule::translateActToPrimitive(CInstanceMap& components, C
CObject* eventObject = events->getValue(firstEvent);
bool isTriggerZone = false;
if ( eventObject->isNumber("IsTriggerZone") )
if ( eventObject->isInteger("IsTriggerZone") )
{
isTriggerZone = static_cast<uint32>(eventObject->toNumber("IsTriggerZone")) == 1;
isTriggerZone = static_cast<uint32>(eventObject->toInteger("IsTriggerZone")) == 1;
}
if (isTriggerZone)
{
@ -1788,7 +1788,7 @@ bool CServerAnimationModule::translateActToPrimitive(CInstanceMap& components, C
CObject *weatherValue = act->getAttr("WeatherValue");
if (weatherValue)
{
animSession->Acts[actId]->WeatherValue = (uint16) weatherValue->toNumber();
animSession->Acts[actId]->WeatherValue = (uint16) weatherValue->toInteger();
}
@ -1901,7 +1901,7 @@ bool CServerAnimationModule::doMakeAnimationSession(CAnimationSession* animSessi
CObject* plotItem = plotItems->getValue(firstPlotItem);
if (!plotItem
|| !plotItem->isTable()
|| !plotItem->isNumber("SheetId")
|| !plotItem->isInteger("SheetId")
|| !plotItem->isString("Name")
|| !plotItem->isString("Description")
|| !plotItem->isString("Comment")
@ -1911,7 +1911,7 @@ bool CServerAnimationModule::doMakeAnimationSession(CAnimationSession* animSessi
return false;
}
uint32 sheetIdAsInt = static_cast<uint32>(plotItem->toNumber("SheetId"));
uint32 sheetIdAsInt = static_cast<uint32>(plotItem->toInteger("SheetId"));
CSheetId plotItemSheetId( sheetIdAsInt );
@ -1958,7 +1958,7 @@ bool CServerAnimationModule::doMakeAnimationSession(CAnimationSession* animSessi
CObject* location = locations->getValue(firstLocation);
if (!location
|| !location->isTable()
|| !location->isNumber("Season")
|| !location->isInteger("Season")
|| !location->isString("Island")
|| !location->isString("EntryPoint")
@ -1969,7 +1969,7 @@ bool CServerAnimationModule::doMakeAnimationSession(CAnimationSession* animSessi
}
CRtLocation locationItem;
locationItem.Season = static_cast<uint8>(location->toNumber("Season"));
locationItem.Season = static_cast<uint8>(location->toInteger("Season"));
locationItem.Island = location->toString("Island");
locationItem.EntryPoint = location->toString("EntryPoint");
animSession->Locations.push_back(locationItem);

View file

@ -113,7 +113,7 @@ CSmallStringManager::CSmallStringManager(CObject* textManager)
return;
}
CObject* texts = textManager->getAttr("Texts");
uint32 maxId = static_cast<uint32>(textManager->getAttr("MaxId")->toNumber());
uint32 maxId = static_cast<uint32>(textManager->getAttr("MaxId")->toInteger());
CObject* unused = textManager->getAttr("UnusedIds");
uint32 max = unused->getSize();
@ -123,7 +123,7 @@ CSmallStringManager::CSmallStringManager(CObject* textManager)
//unused ids
for(uint32 i=0;i<max;i++)
{
uint32 id = static_cast<uint32>(unused->getValue(i)->toNumber());
uint32 id = static_cast<uint32>(unused->getValue(i)->toInteger());
_FreeIds.insert(id);
}
@ -133,8 +133,8 @@ CSmallStringManager::CSmallStringManager(CObject* textManager)
{
CObject* entry = texts->getValue(i);
std::string text = entry->getAttr("Text")->toString();
uint32 textId = static_cast<uint32>(entry->getAttr("TextId")->toNumber());
uint32 textCount = static_cast<uint32>(entry->getAttr("Count")->toNumber());
uint32 textId = static_cast<uint32>(entry->getAttr("TextId")->toInteger());
uint32 textCount = static_cast<uint32>(entry->getAttr("Count")->toInteger());
_StringToId.insert(std::pair<std::string, uint32>(text, textId));
_IdToString.insert( std::pair<uint32, std::pair<std::string, uint32> >(textId, std::pair<std::string, uint32>(text, textCount) ) );
}

View file

@ -35,7 +35,7 @@ void CWeatherManager::init(const std::vector<const CWeatherSetupSheetBase *> &sh
{
if (sheets[k])
{
std::string id = NLMISC::strlwr(NLMISC::CFile::getFilenameWithoutExtension(sheetNames[k]));
std::string id = NLMISC::toLower(NLMISC::CFile::getFilenameWithoutExtension(sheetNames[k]));
CWeatherSetup *ws = newWeatherSetup();
if (ws)
{
@ -70,7 +70,7 @@ void CWeatherManager::release()
//================================================================================================
const CWeatherSetup *CWeatherManager::getSetup(const char *name) const
{
std::string id = NLMISC::strlwr(CFile::getFilenameWithoutExtension(name));
std::string id = NLMISC::toLower(CFile::getFilenameWithoutExtension(name));
TWeatherSetupMap::const_iterator it = _WeatherSetupMap.find(id);
if (it == _WeatherSetupMap.end()) return NULL;
return it->second;

View file

@ -85,7 +85,7 @@ void CWeatherStateSheet::build(const NLGEORGES::UFormElm &item)
GetWeatherFormValue(item, fxName, "FXName");
if (!fxName.empty())
{
fxName = NLMISC::strlwr(NLMISC::CFile::getFilenameWithoutExtension(fxName));
fxName = NLMISC::toLower(NLMISC::CFile::getFilenameWithoutExtension(fxName));
if (!fxName.empty())
{
FXInfos.resize(1);
@ -192,7 +192,7 @@ void CWeatherSetupSheetBase::build(const NLGEORGES::UFormElm &item)
CloudState.build(item);
std::string setupName;
GetWeatherFormValue(item, setupName, "SetupName");
SetupName = NLMISC::CStringMapper::map(NLMISC::strlwr(setupName));
SetupName = NLMISC::CStringMapper::map(NLMISC::toLower(setupName));
}
//==================================================================================
@ -203,7 +203,7 @@ void CWeatherSetupSheetBase::serial(class NLMISC::IStream &f) throw(NLMISC::EStr
{
std::string setupName;
f.serial(setupName);
SetupName = NLMISC::CStringMapper::map(NLMISC::strlwr(setupName));
SetupName = NLMISC::CStringMapper::map(NLMISC::toLower(setupName));
}
else
{