mirror of
https://github.com/TES3MP/TES3MP.git
synced 2025-09-28 23:51:09 -04:00
Fixed some build warnings and IsTimerElapsed function
This commit is contained in:
parent
075b600b3a
commit
5a6c1750d9
@ -13,12 +13,12 @@ using namespace mwmp;
|
|||||||
|
|
||||||
int ScriptFunctions::CreateTimer(ScriptFunc callback, int msec) noexcept
|
int ScriptFunctions::CreateTimer(ScriptFunc callback, int msec) noexcept
|
||||||
{
|
{
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ScriptFunctions::CreateTimerEx(ScriptFunc callback, int msec, const char *types, ...) noexcept
|
int ScriptFunctions::CreateTimerEx(ScriptFunc callback, int msec, const char *types, ...) noexcept
|
||||||
{
|
{
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptFunctions::StartTimer(int timerId) noexcept
|
void ScriptFunctions::StartTimer(int timerId) noexcept
|
||||||
@ -43,7 +43,7 @@ void ScriptFunctions::FreeTimer(int timerId) noexcept
|
|||||||
|
|
||||||
bool ScriptFunctions::IsTimerElapsed(int timerId) noexcept
|
bool ScriptFunctions::IsTimerElapsed(int timerId) noexcept
|
||||||
{
|
{
|
||||||
TimerAPI::IsEndTimer(timerId);
|
return TimerAPI::IsEndTimer(timerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ void LangLua::LoadProgram(const char *filename)
|
|||||||
|
|
||||||
luabridge::Namespace tes3mp = luabridge::getGlobalNamespace(lua).beginNamespace("tes3mp");
|
luabridge::Namespace tes3mp = luabridge::getGlobalNamespace(lua).beginNamespace("tes3mp");
|
||||||
|
|
||||||
for(int i = 0; i < functions_n; i++)
|
for(unsigned i = 0; i < functions_n; i++)
|
||||||
tes3mp.addCFunction(functions_[i].name, functions_[i].func);
|
tes3mp.addCFunction(functions_[i].name, functions_[i].func);
|
||||||
|
|
||||||
tes3mp.endNamespace();
|
tes3mp.endNamespace();
|
||||||
@ -121,6 +121,7 @@ void LangLua::LoadProgram(const char *filename)
|
|||||||
int LangLua::FreeProgram()
|
int LangLua::FreeProgram()
|
||||||
{
|
{
|
||||||
lua_close(lua);
|
lua_close(lua);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LangLua::IsCallbackPresent(const char *name)
|
bool LangLua::IsCallbackPresent(const char *name)
|
||||||
@ -135,7 +136,7 @@ boost::any LangLua::Call(const char *name, const char *argl, int buf, ...)
|
|||||||
std::vector<boost::any> args;
|
std::vector<boost::any> args;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
unsigned int len = strlen(argl);
|
size_t len = strlen(argl);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < len; ++i)
|
for (unsigned int i = 0; i < len; ++i)
|
||||||
{
|
{
|
||||||
|
@ -40,10 +40,10 @@ public:
|
|||||||
LangLua(lua_State *lua);
|
LangLua(lua_State *lua);
|
||||||
~LangLua();
|
~LangLua();
|
||||||
static int MakePublic(lua_State *lua) noexcept;
|
static int MakePublic(lua_State *lua) noexcept;
|
||||||
static int CallPublic(lua_State *lua) noexcept;
|
static int CallPublic(lua_State *lua);
|
||||||
|
|
||||||
static int CreateTimer(lua_State *lua) noexcept;
|
static int CreateTimer(lua_State *lua) noexcept;
|
||||||
static int CreateTimerEx(lua_State *lua) noexcept;
|
static int CreateTimerEx(lua_State *lua);
|
||||||
|
|
||||||
virtual void LoadProgram(const char *filename) override;
|
virtual void LoadProgram(const char *filename) override;
|
||||||
virtual int FreeProgram() override;
|
virtual int FreeProgram() override;
|
||||||
|
@ -76,7 +76,7 @@ int LangLua::MakePublic(lua_State *lua) noexcept
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int LangLua::CallPublic(lua_State *lua) noexcept
|
int LangLua::CallPublic(lua_State *lua)
|
||||||
{
|
{
|
||||||
const char * name = luabridge::Stack<const char*>::get(lua, 1);
|
const char * name = luabridge::Stack<const char*>::get(lua, 1);
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ int LangLua::CallPublic(lua_State *lua) noexcept
|
|||||||
|
|
||||||
string types = Public::GetDefinition(name);
|
string types = Public::GetDefinition(name);
|
||||||
|
|
||||||
if(args_n != types.size())
|
if(args_n != (long)types.size())
|
||||||
throw invalid_argument("Script call: Number of arguments does not match definition");
|
throw invalid_argument("Script call: Number of arguments does not match definition");
|
||||||
|
|
||||||
vector<boost::any> args = DefToVec(lua, types, 2, args_n);
|
vector<boost::any> args = DefToVec(lua, types, 2, args_n);
|
||||||
@ -115,7 +115,7 @@ int LangLua::CreateTimer(lua_State *lua) noexcept
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LangLua::CreateTimerEx(lua_State *lua) noexcept
|
int LangLua::CreateTimerEx(lua_State *lua)
|
||||||
{
|
{
|
||||||
const char * callback = luabridge::Stack<const char*>::get(lua, 1);
|
const char * callback = luabridge::Stack<const char*>::get(lua, 1);
|
||||||
int msec = luabridge::Stack<int>::get(lua, 2);
|
int msec = luabridge::Stack<int>::get(lua, 2);
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
class Language
|
class Language
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
virtual ~Language(){}
|
||||||
virtual void LoadProgram(const char* filename) = 0;
|
virtual void LoadProgram(const char* filename) = 0;
|
||||||
virtual int FreeProgram() = 0;
|
virtual int FreeProgram() = 0;
|
||||||
virtual bool IsCallbackPresent(const char* name) = 0;
|
virtual bool IsCallbackPresent(const char* name) = 0;
|
||||||
|
@ -47,8 +47,8 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::string def;
|
|
||||||
char ret_type;
|
char ret_type;
|
||||||
|
std::string def;
|
||||||
int script_type;
|
int script_type;
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -80,6 +80,7 @@ void ScriptFunctions::GetArguments(std::vector<boost::any> ¶ms, va_list args
|
|||||||
va_end(args);
|
va_end(args);
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptFunctions::MakePublic(ScriptFunc _public, const char *name, char ret_type, const char *def) noexcept
|
void ScriptFunctions::MakePublic(ScriptFunc _public, const char *name, char ret_type, const char *def) noexcept
|
||||||
|
@ -57,7 +57,7 @@ string Utils::str_replace(const string& source, const char* find, const char* re
|
|||||||
{
|
{
|
||||||
unsigned int find_len = strlen(find);
|
unsigned int find_len = strlen(find);
|
||||||
unsigned int replace_len = strlen(replace);
|
unsigned int replace_len = strlen(replace);
|
||||||
long pos = 0;
|
size_t pos = 0;
|
||||||
|
|
||||||
string dest = source;
|
string dest = source;
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ string Utils::str_replace(const string& source, const char* find, const char* re
|
|||||||
|
|
||||||
string& Utils::RemoveExtension(string& file)
|
string& Utils::RemoveExtension(string& file)
|
||||||
{
|
{
|
||||||
unsigned int pos = file.find_last_of('.');
|
size_t pos = file.find_last_of('.');
|
||||||
|
|
||||||
if (pos)
|
if (pos)
|
||||||
file = file.substr(0, pos);
|
file = file.substr(0, pos);
|
||||||
@ -80,7 +80,7 @@ string& Utils::RemoveExtension(string& file)
|
|||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int Utils::FileLength(const char* file)
|
long int Utils::FileLength(const char* file)
|
||||||
{
|
{
|
||||||
FILE* _file = fopen(file, "rb");
|
FILE* _file = fopen(file, "rb");
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ unsigned int Utils::FileLength(const char* file)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
fseek(_file, 0, SEEK_END);
|
fseek(_file, 0, SEEK_END);
|
||||||
unsigned int size = ftell(_file);
|
long int size = ftell(_file);
|
||||||
fclose(_file);
|
fclose(_file);
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
|
@ -38,7 +38,7 @@ namespace Utils
|
|||||||
|
|
||||||
std::string &RemoveExtension(std::string &file);
|
std::string &RemoveExtension(std::string &file);
|
||||||
|
|
||||||
unsigned int FileLength(const char *file);
|
long int FileLength(const char *file);
|
||||||
|
|
||||||
unsigned int crc32buf(char *buf, size_t len);
|
unsigned int crc32buf(char *buf, size_t len);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user