Skip to content

Commit

Permalink
Replaced FNV1a/fasthash with CityHash, reworked `BinaryShaderCa…
Browse files Browse the repository at this point in the history
…che`, fixed `RenderBatcher`, use `static_cast`
  • Loading branch information
deathkiller committed Nov 5, 2023
1 parent b890262 commit 209f834
Show file tree
Hide file tree
Showing 26 changed files with 634 additions and 155 deletions.
1 change: 1 addition & 0 deletions Sources/Jazz2.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@
<ClInclude Include="$(ExtensionLibraryPath)\IO\FileSystem.h" />
<ClInclude Include="$(ExtensionLibraryPath)\IO\MemoryStream.h" />
<ClInclude Include="$(ExtensionLibraryPath)\IO\Stream.h" />
<ClInclude Include="$(ExtensionLibraryPath)\Base\Unaligned.h" />
<ClInclude Include="Common.h" />
<ClInclude Include="Jazz2\Actors\ActorBase.h" />
<ClInclude Include="Jazz2\Actors\Collectibles\CarrotCollectible.h" />
Expand Down
12 changes: 12 additions & 0 deletions Sources/Jazz2.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@
<Filter Include="Header Files\Jazz2\Multiplayer\Backends">
<UniqueIdentifier>{8e8a53f2-8324-4eaa-ab44-82141d569c85}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Shared\Base">
<UniqueIdentifier>{0fd6dab6-c92b-45ba-a620-98604d239e84}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Resources.h">
Expand Down Expand Up @@ -1383,6 +1386,12 @@
<ClInclude Include="Jazz2\Multiplayer\Reason.h">
<Filter>Header Files\Jazz2\Multiplayer</Filter>
</ClInclude>
<ClInclude Include="Jazz2\Multiplayer\ConnectionResult.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="$(ExtensionLibraryPath)\Base\Unaligned.h">
<Filter>Header Files\Shared\Base</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Main.cpp">
Expand Down Expand Up @@ -2291,6 +2300,9 @@
<ClCompile Include="Jazz2\Resources.cpp">
<Filter>Source Files\Jazz2</Filter>
</ClCompile>
<ClCompile Include="Jazz2\Multiplayer\ConnectionResult.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Resources.rc">
Expand Down
4 changes: 2 additions & 2 deletions Sources/Jazz2/Multiplayer/NetworkManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ namespace Jazz2::Multiplayer

void NetworkManager::OnClientThread(void* param)
{
NetworkManager* _this = reinterpret_cast<NetworkManager*>(param);
NetworkManager* _this = static_cast<NetworkManager*>(param);
INetworkHandler* handler = _this->_handler;
ENetHost* host = _this->_host;

Expand Down Expand Up @@ -252,7 +252,7 @@ namespace Jazz2::Multiplayer

void NetworkManager::OnServerThread(void* param)
{
NetworkManager* _this = reinterpret_cast<NetworkManager*>(param);
NetworkManager* _this = static_cast<NetworkManager*>(param);
INetworkHandler* handler = _this->_handler;
ENetHost* host = _this->_host;

Expand Down
70 changes: 35 additions & 35 deletions Sources/Jazz2/Scripting/JJ2PlusDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ namespace Jazz2::Scripting
noop();

auto ctx = asGetActiveContext();
auto owner = reinterpret_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));
auto owner = static_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));

void* mem = asAllocMem(sizeof(jjSTREAM));
return new(mem) jjSTREAM();
Expand All @@ -176,7 +176,7 @@ namespace Jazz2::Scripting
noop();

auto ctx = asGetActiveContext();
auto owner = reinterpret_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));
auto owner = static_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));

void* mem = asAllocMem(sizeof(jjSTREAM));
return new(mem) jjSTREAM();
Expand Down Expand Up @@ -438,7 +438,7 @@ namespace Jazz2::Scripting
noop();

auto ctx = asGetActiveContext();
auto owner = reinterpret_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));
auto owner = static_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));

void* mem = asAllocMem(sizeof(jjANIMFRAME));
return new(mem) jjANIMFRAME();
Expand Down Expand Up @@ -498,7 +498,7 @@ namespace Jazz2::Scripting
noop();

auto ctx = asGetActiveContext();
auto owner = reinterpret_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));
auto owner = static_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));

void* mem = asAllocMem(sizeof(jjANIMATION));
return new(mem) jjANIMATION(index);
Expand Down Expand Up @@ -542,7 +542,7 @@ namespace Jazz2::Scripting
noop();

auto ctx = asGetActiveContext();
auto owner = reinterpret_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));
auto owner = static_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));

void* mem = asAllocMem(sizeof(jjANIMSET));
return new(mem) jjANIMSET(index);
Expand Down Expand Up @@ -839,7 +839,7 @@ namespace Jazz2::Scripting
{
noop();
auto ctx = asGetActiveContext();
auto owner = reinterpret_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));
auto owner = static_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));

void* mem = asAllocMem(sizeof(jjOBJ));
return new(mem) jjOBJ();
Expand All @@ -849,7 +849,7 @@ namespace Jazz2::Scripting
{
noop();
auto ctx = asGetActiveContext();
auto owner = reinterpret_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));
auto owner = static_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));

void* mem = asAllocMem(sizeof(jjOBJ));
return new(mem) jjOBJ();
Expand Down Expand Up @@ -1415,14 +1415,14 @@ namespace Jazz2::Scripting

int32_t get_jjPlayerCount() {
auto ctx = asGetActiveContext();
auto owner = reinterpret_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));
auto owner = static_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));

void* mem = asAllocMem(sizeof(jjPLAYER));
return owner->GetPlayers().size();
}
int32_t get_jjLocalPlayerCount() {
auto ctx = asGetActiveContext();
auto owner = reinterpret_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));
auto owner = static_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));

void* mem = asAllocMem(sizeof(jjPLAYER));
return owner->GetPlayers().size();
Expand All @@ -1432,7 +1432,7 @@ namespace Jazz2::Scripting
noop();

auto ctx = asGetActiveContext();
auto owner = reinterpret_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));
auto owner = static_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));

void* mem = asAllocMem(sizeof(jjPLAYER));
return new(mem) jjPLAYER(owner, 0);
Expand All @@ -1441,7 +1441,7 @@ namespace Jazz2::Scripting
noop();

auto ctx = asGetActiveContext();
auto owner = reinterpret_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));
auto owner = static_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));

void* mem = asAllocMem(sizeof(jjPLAYER));
return new(mem) jjPLAYER(owner, index);
Expand All @@ -1450,7 +1450,7 @@ namespace Jazz2::Scripting
noop();

auto ctx = asGetActiveContext();
auto owner = reinterpret_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));
auto owner = static_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));

void* mem = asAllocMem(sizeof(jjPLAYER));
return new(mem) jjPLAYER(owner, index);
Expand All @@ -1467,7 +1467,7 @@ namespace Jazz2::Scripting
noop();

auto ctx = asGetActiveContext();
auto owner = reinterpret_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));
auto owner = static_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));

void* mem = asAllocMem(sizeof(jjPIXELMAP));
return new(mem) jjPIXELMAP();
Expand All @@ -1476,7 +1476,7 @@ namespace Jazz2::Scripting
noop();

auto ctx = asGetActiveContext();
auto owner = reinterpret_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));
auto owner = static_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));

void* mem = asAllocMem(sizeof(jjPIXELMAP));
return new(mem) jjPIXELMAP();
Expand All @@ -1485,7 +1485,7 @@ namespace Jazz2::Scripting
noop();

auto ctx = asGetActiveContext();
auto owner = reinterpret_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));
auto owner = static_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));

void* mem = asAllocMem(sizeof(jjPIXELMAP));
return new(mem) jjPIXELMAP();
Expand All @@ -1494,7 +1494,7 @@ namespace Jazz2::Scripting
noop();

auto ctx = asGetActiveContext();
auto owner = reinterpret_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));
auto owner = static_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));

void* mem = asAllocMem(sizeof(jjPIXELMAP));
return new(mem) jjPIXELMAP();
Expand All @@ -1503,7 +1503,7 @@ namespace Jazz2::Scripting
noop();

auto ctx = asGetActiveContext();
auto owner = reinterpret_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));
auto owner = static_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));

void* mem = asAllocMem(sizeof(jjPIXELMAP));
return new(mem) jjPIXELMAP();
Expand All @@ -1512,7 +1512,7 @@ namespace Jazz2::Scripting
noop();

auto ctx = asGetActiveContext();
auto owner = reinterpret_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));
auto owner = static_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));

void* mem = asAllocMem(sizeof(jjPIXELMAP));
return new(mem) jjPIXELMAP();
Expand All @@ -1521,7 +1521,7 @@ namespace Jazz2::Scripting
noop();

auto ctx = asGetActiveContext();
auto owner = reinterpret_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));
auto owner = static_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));

void* mem = asAllocMem(sizeof(jjPIXELMAP));
return new(mem) jjPIXELMAP();
Expand Down Expand Up @@ -1578,7 +1578,7 @@ namespace Jazz2::Scripting
noop();

auto ctx = asGetActiveContext();
auto owner = reinterpret_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));
auto owner = static_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));

void* mem = asAllocMem(sizeof(jjMASKMAP));
return new(mem) jjMASKMAP();
Expand All @@ -1587,7 +1587,7 @@ namespace Jazz2::Scripting
noop();

auto ctx = asGetActiveContext();
auto owner = reinterpret_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));
auto owner = static_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));

void* mem = asAllocMem(sizeof(jjMASKMAP));
return new(mem) jjMASKMAP();
Expand Down Expand Up @@ -1664,7 +1664,7 @@ namespace Jazz2::Scripting
noop();

auto ctx = asGetActiveContext();
auto owner = reinterpret_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));
auto owner = static_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(ScriptLoader::EngineToOwner));

void* mem = asAllocMem(sizeof(jjLAYER));
return new(mem) jjLAYER();
Expand Down Expand Up @@ -1776,7 +1776,7 @@ namespace Jazz2::Scripting
noop();

auto ctx = asGetActiveContext();
auto _this = reinterpret_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(EngineToOwner));
auto _this = static_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(EngineToOwner));
return _this->_levelHandler->_musicCurrentPath;
}
String get_jjTilesetFileName() {
Expand All @@ -1787,14 +1787,14 @@ namespace Jazz2::Scripting
noop();

auto ctx = asGetActiveContext();
auto _this = reinterpret_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(EngineToOwner));
auto _this = static_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(EngineToOwner));
return _this->_levelHandler->GetLevelText(index);
}
void LevelScriptLoader::set_jjHelpStrings(uint32_t index, const String& text) {
noop();

auto ctx = asGetActiveContext();
auto _this = reinterpret_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(EngineToOwner));
auto _this = static_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(EngineToOwner));
_this->_levelHandler->OverrideLevelText(index, text);
}

Expand All @@ -1807,7 +1807,7 @@ namespace Jazz2::Scripting
void LevelScriptLoader::jjAlert(const String& text, bool sendToAll, uint32_t size)
{
auto ctx = asGetActiveContext();
auto _this = reinterpret_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(EngineToOwner));
auto _this = static_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(EngineToOwner));
_this->_levelHandler->ShowLevelText(text);
}
void jjPrint(const String& text, bool timestamp) {
Expand Down Expand Up @@ -1993,22 +1993,22 @@ namespace Jazz2::Scripting
//noop();

auto ctx = asGetActiveContext();
auto _this = reinterpret_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(EngineToOwner));
auto _this = static_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(EngineToOwner));
return _this->_levelHandler->GetTrigger(id);
}
bool LevelScriptLoader::set_jjTriggers(uint8_t id, bool value) {
//noop();

auto ctx = asGetActiveContext();
auto _this = reinterpret_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(EngineToOwner));
auto _this = static_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(EngineToOwner));
_this->_levelHandler->SetTrigger(id, value);
return value;
}
bool LevelScriptLoader::jjSwitchTrigger(uint8_t id) {
//noop();

auto ctx = asGetActiveContext();
auto _this = reinterpret_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(EngineToOwner));
auto _this = static_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(EngineToOwner));
_this->_levelHandler->SetTrigger(id, !_this->_levelHandler->GetTrigger(id));
return _this->_levelHandler->GetTrigger(id);
}
Expand Down Expand Up @@ -2070,7 +2070,7 @@ namespace Jazz2::Scripting
}

auto ctx = asGetActiveContext();
auto _this = reinterpret_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(EngineToOwner));
auto _this = static_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(EngineToOwner));
_this->_levelHandler->BeginLevelChange(exitType, { });
}

Expand All @@ -2092,7 +2092,7 @@ namespace Jazz2::Scripting
noop();

auto ctx = asGetActiveContext();
auto _this = reinterpret_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(EngineToOwner));
auto _this = static_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(EngineToOwner));
_this->_levelHandler->BeginPlayMusic(filename, !temporary, forceReload);

return false;
Expand All @@ -2101,7 +2101,7 @@ namespace Jazz2::Scripting
noop();

auto ctx = asGetActiveContext();
auto _this = reinterpret_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(EngineToOwner));
auto _this = static_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(EngineToOwner));
if (_this->_levelHandler->_music != nullptr) {
_this->_levelHandler->_music->stop();
}
Expand All @@ -2110,7 +2110,7 @@ namespace Jazz2::Scripting
noop();

auto ctx = asGetActiveContext();
auto _this = reinterpret_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(EngineToOwner));
auto _this = static_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(EngineToOwner));
if (_this->_levelHandler->_music != nullptr) {
_this->_levelHandler->_music->play();
}
Expand All @@ -2119,7 +2119,7 @@ namespace Jazz2::Scripting
noop();

auto ctx = asGetActiveContext();
auto _this = reinterpret_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(EngineToOwner));
auto _this = static_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(EngineToOwner));
if (_this->_levelHandler->_music != nullptr) {
_this->_levelHandler->_music->stop();
}
Expand All @@ -2128,7 +2128,7 @@ namespace Jazz2::Scripting
noop();

auto ctx = asGetActiveContext();
auto _this = reinterpret_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(EngineToOwner));
auto _this = static_cast<LevelScriptLoader*>(ctx->GetEngine()->GetUserData(EngineToOwner));
if (_this->_levelHandler->_music != nullptr && _this->_levelHandler->_music->isPaused()) {
_this->_levelHandler->_music->play();
}
Expand Down
Loading

0 comments on commit 209f834

Please sign in to comment.