Skip to content

Commit de27569

Browse files
committed
~ Additional logging when using level.vertex_position (FOUND A FEW BAD BUGS IN SCRIPTS WITH THIS!)
~ Exported level.valid_vertex(number) | Use it before level.vertex_position especially! - removed some verify for weapon params, allowing them to be zero, since Epsilon is set ~ CConsole::ExecuteCommand | line_edit::remove_spaces(edt) commented and replaced with _Trim(edt).
1 parent 1102953 commit de27569

File tree

9 files changed

+37
-16
lines changed

9 files changed

+37
-16
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
This repository contains XRAY Engine sources based on version 1.6.02 for specific use with the Call of Chernobyl modification.
55
The original engine is used in S.T.A.L.K.E.R. Call of Pripyat game released by GSC Game World and any changes to this engine are allowed for ***non-commercial*** use only (see [License.txt](https://github.com/avoitishin/xray-16/blob/master/License.txt) for details).
66

7+
The goal of this project is to expand the moddability and features of the engine; Fixing issues or bugs when necessary. It is not to reshape or rebuild X-Ray using modern technology.
8+
79
## Build Instructions
810
This project is maintained under Visual Studio 2013.
911
You need https://developer.microsoft.com/en-us/windows/downloads/windows-8-1-sdk

src/Layers/xrRender/Light_DB.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ void CLight_DB::Update ()
202202
light* _sun_original = (light*) sun_original._get();
203203
light* _sun_adapted = (light*) sun_adapted._get();
204204
CEnvDescriptor& E = *g_pGamePersistent->Environment().CurrentEnv;
205-
VERIFY (_valid(E.sun_dir));
205+
//VERIFY (_valid(E.sun_dir));
206206
#ifdef DEBUG
207207
if(E.sun_dir.y>=0)
208208
{

src/xrEngine/IGame_ObjectPool.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,14 @@ void IGame_ObjectPool::clear()
5151

5252
CObject* IGame_ObjectPool::create(LPCSTR name)
5353
{
54-
CLASS_ID CLS = pSettings->r_clsid(name, "class");
55-
CObject* O = (CObject*)NEW_INSTANCE(CLS);
54+
CLASS_ID CLS = pSettings->r_clsid(name, "class");
55+
CObject* O = (CObject*)NEW_INSTANCE(CLS);
56+
if (!O)
57+
{
58+
LogStackTrace("");
59+
Msg("xrFactory_Create | failed to create %s by clsid %d", name, CLS);
60+
return (0);
61+
}
5662
O->cNameSect_set(name);
5763
O->Load(name);
5864
return O;

src/xrEngine/XR_IOConsole.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,9 @@ void CConsole::ExecuteCommand(LPCSTR cmd_str, bool record_cmd)
579579
reset_cmd_history_idx();
580580
reset_selected_tip();
581581

582-
text_editor::remove_spaces(edt);
582+
//text_editor::remove_spaces(edt);
583+
_Trim(edt);
584+
583585
if (edt[0] == 0)
584586
{
585587
return;

src/xrGame/Level_network_spawn.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,10 @@ void CLevel::g_sv_Spawn (CSE_Abstract* E)
112112
#ifdef DEBUG_MEMORY_MANAGER
113113
mem_alloc_gather_stats (false);
114114
#endif // DEBUG_MEMORY_MANAGER
115-
if (0==O || (!O->net_Spawn (E)))
115+
if (O == 0)
116+
{
117+
Msg("! Failed to spawn entity '%s'", *E->s_name);
118+
}else if (!O->net_Spawn(E))
116119
{
117120
O->net_Destroy ( );
118121
if(!g_dedicated_server)

src/xrGame/ShootingObject.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,10 @@ void CShootingObject::Load (LPCSTR section)
6868

6969
//âðåìÿ çàòðà÷èâàåìîå íà âûñòðåë
7070
fOneShotTime = pSettings->r_float (section,"rpm");
71-
71+
if(fis_zero(fOneShotTime))
72+
fOneShotTime = EPS;
7273
//Alundaio: Two-shot burst rpm; used for Abakan/AN-94
7374
fModeShotTime = READ_IF_EXISTS(pSettings, r_float, section, "rpm_mode_2", fOneShotTime);
74-
75-
VERIFY(fOneShotTime>0.f);
7675
fOneShotTime = 60.f / fOneShotTime;
7776
fModeShotTime = 60.f / fModeShotTime;
7877

src/xrGame/Weapon.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,7 @@ void CWeapon::Load(LPCSTR section)
260260
float temp_f = 0.0f;
261261
temp_f = pSettings->r_float(section, "cam_relax_speed");
262262
cam_recoil.RelaxSpeed = _abs(deg2rad(temp_f));
263-
//AVO: commented out as very minor and is clashing with weapon mods
264-
//UNDONE after non fatal VERIFY implementation
265-
VERIFY(!fis_zero(cam_recoil.RelaxSpeed));
263+
//VERIFY(!fis_zero(cam_recoil.RelaxSpeed));
266264
if (fis_zero(cam_recoil.RelaxSpeed))
267265
{
268266
cam_recoil.RelaxSpeed = EPS_L;
@@ -281,15 +279,15 @@ void CWeapon::Load(LPCSTR section)
281279
}
282280
temp_f = pSettings->r_float(section, "cam_max_angle");
283281
cam_recoil.MaxAngleVert = _abs(deg2rad(temp_f));
284-
VERIFY(!fis_zero(cam_recoil.MaxAngleVert));
282+
//VERIFY(!fis_zero(cam_recoil.MaxAngleVert));
285283
if (fis_zero(cam_recoil.MaxAngleVert))
286284
{
287285
cam_recoil.MaxAngleVert = EPS;
288286
}
289287

290288
temp_f = pSettings->r_float(section, "cam_max_angle_horz");
291289
cam_recoil.MaxAngleHorz = _abs(deg2rad(temp_f));
292-
VERIFY(!fis_zero(cam_recoil.MaxAngleHorz));
290+
//VERIFY(!fis_zero(cam_recoil.MaxAngleHorz));
293291
if (fis_zero(cam_recoil.MaxAngleHorz))
294292
{
295293
cam_recoil.MaxAngleHorz = EPS;

src/xrGame/level_script.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,19 @@ u32 vertex_in_direction(u32 level_vertex_id, Fvector direction, float max_distan
255255

256256
Fvector vertex_position(u32 level_vertex_id)
257257
{
258+
if (!ai().level_graph().valid_vertex_id(level_vertex_id))
259+
{
260+
ai().script_engine().print_stack();
261+
Msg("level.vertex_position | Invalid vertex id %d", level_vertex_id);
262+
}
258263
return (ai().level_graph().vertex_position(level_vertex_id));
259264
}
260265

266+
bool valid_vertex(u32 level_vertex_id)
267+
{
268+
return ai().level_graph().valid_vertex_id(level_vertex_id);
269+
}
270+
261271
void map_add_object_spot(u16 id, LPCSTR spot_type, LPCSTR text)
262272
{
263273
CMapLocation* ml = Level().MapManager().AddMapLocation(spot_type,id);
@@ -831,6 +841,7 @@ void CLevel::script_register(lua_State *L)
831841
def("get_active_cam", &get_active_cam),
832842
def("set_active_cam", &set_active_cam),
833843
def("get_start_time", &get_start_time),
844+
def("valid_vertex", &valid_vertex),
834845
#endif
835846
//Alundaio: END
836847
// obsolete\deprecated

src/xrGame/xrGame.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ extern "C" {
2929
DLL_API DLL_Pure* __cdecl xrFactory_Create (CLASS_ID clsid)
3030
{
3131
DLL_Pure *object = object_factory().client_object(clsid);
32-
#ifdef DEBUG
32+
//#ifdef DEBUG
3333
if (!object)
34-
return (0);
35-
#endif
34+
return (0);
35+
//#endif
3636
object->CLS_ID = clsid;
3737
return (object);
3838
}

0 commit comments

Comments
 (0)