Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LOD management functions #3831

Draft
wants to merge 36 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
6f7c6c6
add shared func getObjectLODModel(int objectModel)
Fernando-A-Rocha Oct 29, 2024
f182db2
Merge branch 'master' into add-lod-model-func
Fernando-A-Rocha Oct 29, 2024
cb928f1
refactor 1
Fernando-A-Rocha Oct 29, 2024
93251bd
new arg parser
Fernando-A-Rocha Oct 30, 2024
d0419a3
Merge branch 'master' into add-lod-model-func
Fernando-A-Rocha Oct 30, 2024
62cb6e8
rename to GetObjectLODOfModel
Fernando-A-Rocha Oct 30, 2024
c648cbb
add getObjectModelOfLOD
Fernando-A-Rocha Oct 30, 2024
405ad8d
refactors
Fernando-A-Rocha Oct 30, 2024
51e8967
refactor
Fernando-A-Rocha Oct 30, 2024
21e7b28
test @TracerDS
Fernando-A-Rocha Oct 30, 2024
6244ebb
fix OBJ_LOD_MODELS array @TracerDS
Fernando-A-Rocha Oct 31, 2024
73a4252
constexpr
Fernando-A-Rocha Oct 31, 2024
832c6bd
Update CLodModels.cpp
Fernando-A-Rocha Nov 1, 2024
be36dc5
Update CLodModels.cpp
Fernando-A-Rocha Nov 1, 2024
765f7aa
rename GetObjectLowLODOfModel and GetObjectHighLODOfModel
Fernando-A-Rocha Nov 2, 2024
c3613f3
Merge branch 'add-lod-model-func' of github.com:Fernando-A-Rocha/mtas…
Fernando-A-Rocha Nov 2, 2024
71fb7f5
incomplete lod array sorted WIP
Fernando-A-Rocha Nov 2, 2024
26f980e
comment
Fernando-A-Rocha Nov 2, 2024
81c971a
Fixed LOD table WIP
Fernando-A-Rocha Nov 2, 2024
1e223ab
funcs refactor
Fernando-A-Rocha Nov 4, 2024
4225df7
uselesss include
Fernando-A-Rocha Nov 4, 2024
caec9d7
del getObjectCustomLowLODModel
Fernando-A-Rocha Nov 4, 2024
a6466f5
Merge branch 'master' into add-lod-model-func
Fernando-A-Rocha Nov 10, 2024
a43f1ad
Merge branch 'master' into add-lod-model-func
Fernando-A-Rocha Nov 18, 2024
9a1fece
Update Shared/mods/deathmatch/logic/CLodModels.h
Fernando-A-Rocha Nov 18, 2024
0b771df
Update Shared/mods/deathmatch/logic/CLodModels.h
Fernando-A-Rocha Nov 18, 2024
9c117fd
optimize lookups
Fernando-A-Rocha Nov 18, 2024
1f3ddc6
comments
Fernando-A-Rocha Nov 18, 2024
e563d71
Merge branch 'master' into add-lod-model-func
Fernando-A-Rocha Nov 20, 2024
50e282e
Merge branch 'master' into add-lod-model-func
Fernando-A-Rocha Nov 22, 2024
70809d5
Merge branch 'master' into add-lod-model-func
Fernando-A-Rocha Nov 25, 2024
5af6b06
rename funcs, add isValidModel WIP
Fernando-A-Rocha Nov 25, 2024
93c98c8
.
Fernando-A-Rocha Nov 25, 2024
cbad928
.
Fernando-A-Rocha Nov 26, 2024
ab63086
isValidModel update
Fernando-A-Rocha Nov 26, 2024
b03ea49
wip
Fernando-A-Rocha Nov 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Client/mods/deathmatch/logic/lua/CLuaFunctionDefs.Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,29 @@
*****************************************************************************/

#include "StdInc.h"
#include "CLodModels.h"

int CLuaFunctionDefs::GetObjectLODModel(lua_State* luaVM)
{
std::uint32_t objectID;
CScriptArgReader argStream(luaVM);
argStream.ReadNumber(objectID);

if (argStream.HasErrors())
{
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());
lua_pushboolean(luaVM, false);
}
else
{
std::uint32_t lodModel = CLodModels::GetObjectLODModel(objectID);
if (lodModel == 0) // LOD Model not found for Object Model provided
lua_pushnil(luaVM);
else
lua_pushnumber(luaVM, lodModel);
}
return 1;
}
Fernando-A-Rocha marked this conversation as resolved.
Show resolved Hide resolved

int CLuaFunctionDefs::GetValidPedModels(lua_State* luaVM)
{
Expand Down
1 change: 1 addition & 0 deletions Client/mods/deathmatch/logic/lua/CLuaFunctionDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class CLuaFunctionDefs
// Util functions to make scripting easier for the end user
// Some of these are based on standard mIRC script funcs as a lot of people will be used to them
LUA_DECLARE(GetValidPedModels);
LUA_DECLARE(GetObjectLODModel);
Fernando-A-Rocha marked this conversation as resolved.
Show resolved Hide resolved
LUA_DECLARE(SetDevelopmentMode);
LUA_DECLARE(GetDevelopmentMode);

Expand Down
1 change: 1 addition & 0 deletions Client/mods/deathmatch/logic/lua/CLuaManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ void CLuaManager::LoadCFunctions()

// Util functions
{"getValidPedModels", CLuaFunctionDefs::GetValidPedModels},
{"getObjectLODModel", CLuaFunctionDefs::GetObjectLODModel},
Fernando-A-Rocha marked this conversation as resolved.
Show resolved Hide resolved
{"downloadFile", CLuaFunctionDefs::DownloadFile},

// Input functions
Expand Down
23 changes: 23 additions & 0 deletions Server/mods/deathmatch/logic/luadefs/CLuaFunctionDefs.Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,36 @@
#include "ASE.h"
#include "CStaticFunctionDefinitions.h"
#include "CPerfStatManager.h"
#include "CLodModels.h"

#define MIN_SERVER_REQ_CALLREMOTE_QUEUE_NAME "1.5.3-9.11270"
#define MIN_SERVER_REQ_CALLREMOTE_CONNECTION_ATTEMPTS "1.3.0-9.04563"
#define MIN_SERVER_REQ_CALLREMOTE_CONNECT_TIMEOUT "1.3.5"
#define MIN_SERVER_REQ_CALLREMOTE_OPTIONS_TABLE "1.5.4-9.11342"
#define MIN_SERVER_REQ_CALLREMOTE_OPTIONS_FORMFIELDS "1.5.4-9.11413"

int CLuaFunctionDefs::GetObjectLODModel(lua_State* luaVM)
{
std::uint32_t objectID;
CScriptArgReader argStream(luaVM);
argStream.ReadNumber(objectID);

if (argStream.HasErrors())
{
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());
lua_pushboolean(luaVM, false);
}
else
{
std::uint32_t lodModel = CLodModels::GetObjectLODModel(objectID);
if (lodModel == 0) // LOD Model not found for Object Model provided
lua_pushnil(luaVM);
else
lua_pushnumber(luaVM, lodModel);
}
return 1;
}
Fernando-A-Rocha marked this conversation as resolved.
Show resolved Hide resolved

int CLuaFunctionDefs::AddCommandHandler(lua_State* luaVM)
{
// bool addCommandHandler ( string commandName, function handlerFunction, [bool restricted = false, bool caseSensitive = true] )
Expand Down
2 changes: 1 addition & 1 deletion Server/mods/deathmatch/logic/luadefs/CLuaFunctionDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void CLuaFunctionDefs::LoadFunctions()
// Utility
{"getVersion", CLuaFunctionDefs::GetVersion}, {"getNetworkUsageData", CLuaFunctionDefs::GetNetworkUsageData},
{"getNetworkStats", CLuaFunctionDefs::GetNetworkStats}, {"getLoadedModules", CLuaFunctionDefs::GetModules},
{"getModuleInfo", CLuaFunctionDefs::GetModuleInfo},
{"getModuleInfo", CLuaFunctionDefs::GetModuleInfo}, {"getObjectLODModel", CLuaFunctionDefs::GetObjectLODModel},
Fernando-A-Rocha marked this conversation as resolved.
Show resolved Hide resolved

{"setDevelopmentMode", CLuaFunctionDefs::SetDevelopmentMode}, {"getDevelopmentMode", CLuaFunctionDefs::GetDevelopmentMode},
};
Expand Down
1 change: 1 addition & 0 deletions Server/mods/deathmatch/logic/luadefs/CLuaFunctionDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class CLuaFunctionDefs : public CLuaDefs
LUA_DECLARE(GetVersion);
LUA_DECLARE(GetModules);
LUA_DECLARE(GetModuleInfo);
LUA_DECLARE(GetObjectLODModel);
Fernando-A-Rocha marked this conversation as resolved.
Show resolved Hide resolved

LUA_DECLARE(SetDevelopmentMode);
LUA_DECLARE(GetDevelopmentMode);
Expand Down
493 changes: 493 additions & 0 deletions Shared/mods/deathmatch/logic/CLodModels.cpp

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions Shared/mods/deathmatch/logic/CLodModels.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*****************************************************************************
*
* PROJECT: Multi Theft Auto v1.0
Fernando-A-Rocha marked this conversation as resolved.
Show resolved Hide resolved
* (Shared logic for modifications)
* LICENSE: See LICENSE in the top level directory
* FILE: mods/shared_logic/CLodModels.h
*
*****************************************************************************/
#pragma once

#include <map>
#include <memory>
#include <cstdint>

class CLodModels
{
public:
static std::uint32_t GetObjectLODModel(std::uint32_t objectID)
{
const auto it = LOD_MODELS->find(objectID);
if (it != LOD_MODELS->end())
{
return it->second;
}
return 0;
};
Fernando-A-Rocha marked this conversation as resolved.
Show resolved Hide resolved

private:
// Static pointer to a map that is initialized in the .cpp file
static std::unique_ptr<const std::map<std::uint32_t, std::uint32_t>> LOD_MODELS;
Fernando-A-Rocha marked this conversation as resolved.
Show resolved Hide resolved
Fernando-A-Rocha marked this conversation as resolved.
Show resolved Hide resolved
};
Loading