Skip to content

Commit 06addea

Browse files
avoitishinXottab-DUTY
authored andcommitted
+ print_stack is exported to global namespace
Xottab_DUTY: temporary workaround to get lua log output
1 parent 8f694c7 commit 06addea

File tree

6 files changed

+29
-15
lines changed

6 files changed

+29
-15
lines changed

src/xrGame/HudItem.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,9 @@ bool CHudItem::isHUDAnimationExist(pcstr anim_name)
366366
else // Third person
367367
if (g_player_hud->motion_length(anim_name, HudSection(), m_current_motion_def) > 100)
368368
return true;
369+
#ifdef DEBUG
369370
Msg("~ [WARNING] ------ Animation [%s] does not exist in [%s]", anim_name, HudSection().c_str());
371+
#endif
370372
return false;
371373
}
372374

src/xrGame/WeaponMagazined.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,15 @@ CWeaponMagazined::~CWeaponMagazined()
6666
void CWeaponMagazined::net_Destroy() { inherited::net_Destroy(); }
6767

6868
//AVO: for custom added sounds check if sound exists
69-
bool CWeaponMagazined::WeaponSoundExist(LPCSTR section, LPCSTR sound_name)
69+
bool CWeaponMagazined::WeaponSoundExist(pcstr section, pcstr sound_name) const
7070
{
7171
pcstr str;
7272
bool sec_exist = process_if_exists_set(section, sound_name, &CInifile::r_string, str, true);
7373
if (sec_exist)
7474
return true;
75+
#ifdef DEBUG
7576
Msg("~ [WARNING] ------ Sound [%s] does not exist in [%s]", sound_name, section);
77+
#endif
7678
return false;
7779
}
7880

@@ -92,6 +94,8 @@ void CWeaponMagazined::Load(LPCSTR section)
9294
#ifdef NEW_SOUNDS //AVO: custom sounds go here
9395
if (WeaponSoundExist(section, "snd_reload_empty"))
9496
m_sounds.LoadSound(section, "snd_reload_empty", "sndReloadEmpty", true, m_eSoundReloadEmpty);
97+
if (WeaponSoundExist(section, "snd_reload_misfire"))
98+
m_sounds.LoadSound(section, "snd_reload_misfire", "sndReloadMisfire", true, m_eSoundReloadMisfire);
9599
#endif //-NEW_SOUNDS
96100

97101
m_sSndShotCurrent = "sndShot";

src/xrGame/WeaponMagazined.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class CWeaponMagazined : public CWeapon
3030
ESoundTypes m_eSoundReload;
3131
#ifdef NEW_SOUNDS //AVO: new sounds go here
3232
ESoundTypes m_eSoundReloadEmpty;
33+
ESoundTypes m_eSoundReloadMisfire;
3334
#endif //-NEW_SOUNDS
3435

3536
bool m_sounds_enabled;
@@ -176,5 +177,5 @@ class CWeaponMagazined : public CWeapon
176177
u16 parent_id, u16 weapon_id, bool send_hit);
177178

178179
//AVO: for custom added sounds check if sound exists
179-
bool WeaponSoundExist(pcstr section, pcstr sound_name);
180+
bool WeaponSoundExist(pcstr section, pcstr sound_name) const;
180181
};

src/xrScriptEngine/ScriptEngineScript.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
void LuaLog(LPCSTR caMessage)
1818
{
19+
if (!GlobalEnv.ScriptEngine->m_stack_is_ready)
20+
Log(caMessage); // Xottab_DUTY: temporary workaround to get lua log output
21+
1922
#ifndef MASTER_GOLD
2023
GlobalEnv.ScriptEngine->script_log(LuaMessageType::Message, "%s", caMessage);
2124
#endif
@@ -27,6 +30,9 @@ void LuaLog(LPCSTR caMessage)
2730

2831
void ErrorLog(LPCSTR caMessage)
2932
{
33+
if (!GlobalEnv.ScriptEngine->m_stack_is_ready)
34+
Log(caMessage); // Xottab_DUTY: temporary workaround to get lua error output
35+
3036
GlobalEnv.ScriptEngine->error_log("%s", caMessage);
3137
#ifdef DEBUG
3238
GlobalEnv.ScriptEngine->print_stack();
@@ -44,6 +50,13 @@ void ErrorLog(LPCSTR caMessage)
4450
#endif
4551
}
4652

53+
//AVO:
54+
void PrintStack()
55+
{
56+
GlobalEnv.ScriptEngine->print_stack();
57+
}
58+
//-AVO
59+
4760
void FlushLogs()
4861
{
4962
#ifdef DEBUG
@@ -149,8 +162,8 @@ SCRIPT_EXPORT(CScriptEngine, (), {
149162
.def("start", &profile_timer_script::start)
150163
.def("stop", &profile_timer_script::stop)
151164
.def("time", &profile_timer_script::time),
152-
def("log", &LuaLog), def("error_log", &ErrorLog), def("flush", &FlushLogs), def("prefetch", &prefetch_module),
153-
def("verify_if_thread_is_running", &verify_if_thread_is_running), def("editor", &is_editor),
165+
def("log", &LuaLog), def("error_log", &ErrorLog), def("flush", &FlushLogs), def("print_stack", &PrintStack),
166+
def("prefetch", &prefetch_module), def("verify_if_thread_is_running", &verify_if_thread_is_running),
154167
def("bit_and", &bit_and), def("bit_or", &bit_or), def("bit_xor", &bit_xor), def("bit_not", &bit_not),
155-
def("user_name", &user_name)];
168+
def("editor", &is_editor), def("user_name", &user_name)];
156169
});

src/xrScriptEngine/script_engine.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,6 @@ int CScriptEngine::vscript_log(LuaMessageType luaMessageType, LPCSTR caFormat, v
251251
#endif
252252
}
253253

254-
#ifdef DEBUG
255254
void CScriptEngine::print_stack()
256255
{
257256
if (!m_stack_is_ready)
@@ -276,7 +275,6 @@ void CScriptEngine::print_stack()
276275
}
277276
}
278277
}
279-
#endif
280278

281279
int CScriptEngine::script_log(LuaMessageType message, LPCSTR caFormat, ...)
282280
{
@@ -643,15 +641,13 @@ void CScriptEngine::print_error(lua_State* L, int iErrorCode)
643641
}
644642
}
645643

646-
#ifdef DEBUG
647644
void CScriptEngine::flush_log()
648645
{
649646
string_path log_file_name;
650647
strconcat(sizeof(log_file_name), log_file_name, Core.ApplicationName, "_", Core.UserName, "_lua.log");
651648
FS.update_path(log_file_name, "$logs$", log_file_name);
652649
m_output.save_to(log_file_name);
653650
}
654-
#endif
655651

656652
int CScriptEngine::error_log(LPCSTR format, ...)
657653
{

src/xrScriptEngine/script_engine.hpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ class XRSCRIPTENGINE_API CScriptEngine
9090
protected:
9191
CScriptProcessStorage m_script_processes;
9292
int m_stack_level;
93-
#ifdef DEBUG
93+
9494
CMemoryWriter m_output; // for call stack
95-
#endif
95+
9696
#ifdef USE_DEBUGGER
9797
#ifndef USE_LUA_STUDIO
9898
CScriptDebugger* m_scriptDebugger;
@@ -103,9 +103,7 @@ class XRSCRIPTENGINE_API CScriptEngine
103103
#endif
104104

105105
public:
106-
#ifdef DEBUG
107106
bool m_stack_is_ready;
108-
#endif
109107

110108
private:
111109
static CScriptEngine* GetInstance(lua_State* state);
@@ -145,10 +143,10 @@ class XRSCRIPTENGINE_API CScriptEngine
145143

146144
public:
147145
static void on_error(lua_State* state);
148-
#ifdef DEBUG
146+
149147
void flush_log();
150148
void print_stack();
151-
#endif
149+
152150
using ExporterFunc = XRay::ScriptExporter::Node::ExporterFunc;
153151
CScriptEngine();
154152
virtual ~CScriptEngine();

0 commit comments

Comments
 (0)