Skip to content

Commit

Permalink
model config fixes
Browse files Browse the repository at this point in the history
fixed entity model configuration loading; renamed script function
getEntityProperties(...) to getEntityModelProperties(...);
  • Loading branch information
TeslaRus committed May 27, 2015
1 parent 1cf8ece commit ebcccb3
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions scripts/entity/entity_properties.lua
Expand Up @@ -1222,7 +1222,7 @@ tr4_entity_tbl[453] = {coll = 0x01}; -- Animating 14 (sunlight)
tr4_entity_tbl[454] = {coll = 0x01}; -- Animating 14 MIP
tr4_entity_tbl[455] = {coll = 0x01}; -- Animating 15 (basket, hub.tr4, sunlight)
tr4_entity_tbl[456] = {coll = 0x01}; -- Animating 15 MIP
tr4_entity_tbl[457] = {coll = 0x01}; -- Animating 16
tr4_entity_tbl[457] = {coll = 0x01}; -- Animating 16 (map 9 - coll = 0x00)
tr4_entity_tbl[458] = {coll = 0x01}; -- Animating 16 MIP

--------------------------------------------------------------------------------
Expand Down Expand Up @@ -1735,7 +1735,7 @@ tr5_entity_tbl[452] = {coll = 0x01}; -- Bridge tilt 2
tr5_entity_tbl[453] = {coll = 0x01}; -- Bridge tilt 2 MIP


function getEntityProperties(ver, id)
function getEntityModelProperties(ver, id)
tbl = {};
if(ver < 3) then -- TR_I, TR_I_DEMO, TR_I_UB
tbl = tr1_entity_tbl;
Expand Down
4 changes: 1 addition & 3 deletions scripts/level/tr3/SHORE.lua
@@ -1,8 +1,6 @@
-- OPENTOMB LEVEL SCRIPT
-- FOR TOMB RAIDER 3, SHORE.TR2

dofile("scripts/staticmesh/staticmesh_script.lua");
print("Level script loaded (SHORE.lua)");

static_tbl[30] = {coll = COLL_BBOX_BASE}; --

print("Level script loaded (SHORE.lua)");
4 changes: 3 additions & 1 deletion scripts/level/tr4/LAKE_autoexec.lua
@@ -1 +1,3 @@
playStream(110)
playStream(110)

This comment has been minimized.

Copy link
@vvs-

vvs- May 27, 2015

Contributor

The next line doesn't work from here for some reason. But it works if applied manually afterwards.

setEntityCollision(88, 0); -- model 457
4 changes: 2 additions & 2 deletions src/entity.cpp
Expand Up @@ -237,7 +237,7 @@ void BT_GenEntityRigidBody(entity_p ent)
btScalar tr[16];
btVector3 localInertia(0, 0, 0);
btTransform startTransform;
btCollisionShape *cshape;

if(ent->bf.animations.model == NULL)
{
return;
Expand All @@ -248,8 +248,8 @@ void BT_GenEntityRigidBody(entity_p ent)
for(uint16_t i=0;i<ent->bf.bone_tag_count;i++)
{
base_mesh_p mesh = ent->bf.animations.model->mesh_tree[i].mesh_base;
btCollisionShape *cshape = BT_CSfromMesh(mesh, true, true, false);
ent->bt_body[i] = NULL;
cshape = BT_CSfromMesh(mesh, true, true, false);

if(cshape)
{
Expand Down
8 changes: 4 additions & 4 deletions src/resource.cpp
Expand Up @@ -50,11 +50,11 @@ void TR_SetEntityModelProperties(struct entity_s *ent)
{
int top = lua_gettop(objects_flags_conf);
assert(top >= 0);
lua_getglobal(objects_flags_conf, "getEntityProperties");
lua_getglobal(objects_flags_conf, "getEntityModelProperties");
if(lua_isfunction(objects_flags_conf, -1))
{
lua_pushinteger(objects_flags_conf, engine_world.version); // engine version
lua_pushinteger(objects_flags_conf, ent->id); // entity id
lua_pushinteger(objects_flags_conf, ent->bf.animations.model->id); // entity model id
if (lua_CallAndLog(objects_flags_conf, 2, 4, 0))
{
ent->self->collide_flag = 0xff & lua_tointeger(objects_flags_conf, -4); // get collision flag
Expand All @@ -74,11 +74,11 @@ void TR_SetEntityModelProperties(struct entity_s *ent)
{
int top = lua_gettop(level_script);
assert(top >= 0);
lua_getglobal(level_script, "getEntityProperties");
lua_getglobal(level_script, "getEntityModelProperties");
if(lua_isfunction(level_script, -1))
{
lua_pushinteger(level_script, engine_world.version); // engine version
lua_pushinteger(level_script, ent->id); // entity id
lua_pushinteger(level_script, ent->bf.animations.model->id); // entity model id
if (lua_CallAndLog(level_script, 2, 4, 0)) // call that function
{
if(!lua_isnil(level_script, -4))
Expand Down

6 comments on commit ebcccb3

@TeslaRus
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The line "setEntityCollision(88, 0);" works if You load level by setgamef(4, 9) (works in my case); load saved game will rewrite collision config because game saves keep collision flags of the entities; If You mean "playStream(110)" - I have no idea, soundtrack works for me, if I use setgamef(4, 9);

@vvs-
Copy link
Contributor

@vvs- vvs- commented on ebcccb3 May 27, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, that's strange... I'm doing the same setgamef(4,9) and can't get past the arch. Only when I do setEntityCollision(88,0) it works for me. There should be some rational explanation to the different results. Somebody else should try it too.

Another possibility is a difference in compiler or OS, which will be difficult to trace.

EDIT: I found the reason: it's the case sensitivity of file names. In TR4.lua level name is lower case and in case sensitive file system it should be too. But the script name in level/tr4 is LAKE_autoexec.lua (note the upper case here). That's why it doesn't work on Linux.

@TeslaRus
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try to add "print("LAKE_autoexec.lua loaded");" to scripts/level/tr4/LAKE_autoexec.lua and try to find "LAKE_autoexec.lua loaded" in console... or use build-clean (it helps in some cases, but I am not sure about this case)...

@vvs-
Copy link
Contributor

@vvs- vvs- commented on ebcccb3 May 27, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works if I rename it to a lower case. Also, I have cannot open scripts/level/tr4/lake.lua: No such file or directory in lua_out.txt. I'll better open a separate issue in this case.

@TeslaRus
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only one idea: I have lake.tr4 level file name, but script file name is LAKE.lua... windows is no case sensitive (LAKE.tr4 == lake.tr4 a.t.c.). to resolve it I need to rewrite function, that generates script name and use only upper or only lower case symbols in file name (and do not touch the path) + rename all level scripts to upper or lower symbols.

@vvs-
Copy link
Contributor

@vvs- vvs- commented on ebcccb3 May 27, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I thought too.

Please sign in to comment.