Changed: Support for integer types in Lua 5.3, fixes #253
This commit is contained in:
parent
380bac5728
commit
c27e1062e4
31 changed files with 644 additions and 247 deletions
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -4725,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);
|
||||
|
@ -4738,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;
|
||||
|
@ -4748,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);
|
||||
|
@ -4775,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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -1183,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());
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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(); }
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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))
|
||||
{
|
||||
|
|
|
@ -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")))
|
||||
{
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) ) );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue