[Logger] Use c++20 format

This commit is contained in:
Edo 2022-06-12 23:07:53 +02:00 committed by GitHub
parent fa4adf12db
commit 020201ab1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
71 changed files with 660 additions and 508 deletions

View File

@ -126,7 +126,7 @@ namespace Components
#ifdef DEBUG #ifdef DEBUG
if (!Loader::IsPerformingUnitTests()) if (!Loader::IsPerformingUnitTests())
{ {
Logger::Print("Unregistering component: %s\n", component->getName().data()); Logger::Print("Unregister component: {}\n", component->getName());
} }
#endif #endif
delete component; delete component;
@ -178,12 +178,12 @@ namespace Components
for (auto component : Loader::Components) for (auto component : Loader::Components)
{ {
#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) #if defined(DEBUG) || defined(FORCE_UNIT_TESTS)
Logger::Print("Testing '%s'...\n", component->getName().data()); Logger::Print("Testing '{}'...\n", component->getName());
#endif #endif
auto startTime = std::chrono::high_resolution_clock::now(); auto startTime = std::chrono::high_resolution_clock::now();
bool testRes = component->unitTest(); bool testRes = component->unitTest();
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() - startTime).count(); auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() - startTime).count();
Logger::Print("Test done (%llims): %s\n\n", duration, (testRes ? "Success" : "Error")); Logger::Print("Test done ({}ms): {}\n\n", duration, (testRes ? "Success" : "Error"));
result &= testRes; result &= testRes;
} }
@ -206,7 +206,7 @@ namespace Components
#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) #if defined(DEBUG) || defined(FORCE_UNIT_TESTS)
if (!Loader::IsPerformingUnitTests()) if (!Loader::IsPerformingUnitTests())
{ {
Logger::Print("Component registered: %s\n", component->getName().data()); Logger::Print("Component registered: {}\n", component->getName());
} }
#endif #endif
Loader::Components.push_back(component); Loader::Components.push_back(component);

View File

@ -25,12 +25,12 @@ namespace Components
if (AssetHandler::AssetInterfaces.contains(iAsset->getType())) if (AssetHandler::AssetInterfaces.contains(iAsset->getType()))
{ {
Logger::Print("Duplicate asset interface: %s\n", Game::DB_GetXAssetTypeName(iAsset->getType())); Logger::Print("Duplicate asset interface: {}\n", Game::DB_GetXAssetTypeName(iAsset->getType()));
delete AssetHandler::AssetInterfaces[iAsset->getType()]; delete AssetHandler::AssetInterfaces[iAsset->getType()];
} }
else else
{ {
Logger::Print("Asset interface registered: %s\n", Game::DB_GetXAssetTypeName(iAsset->getType())); Logger::Print("Asset interface registered: {}\n", Game::DB_GetXAssetTypeName(iAsset->getType()));
} }
AssetHandler::AssetInterfaces[iAsset->getType()] = iAsset; AssetHandler::AssetInterfaces[iAsset->getType()] = iAsset;
@ -96,7 +96,7 @@ namespace Components
if (AssetHandler::BypassState < 0) if (AssetHandler::BypassState < 0)
{ {
AssetHandler::BypassState = 0; AssetHandler::BypassState = 0;
Logger::Error("Bypass state is below 0!"); Logger::Error(Game::ERR_FATAL, "Bypass state is below 0!");
} }
} }
@ -345,7 +345,7 @@ namespace Components
} }
else else
{ {
Logger::Error("No interface for type '%s'!", Game::DB_GetXAssetTypeName(asset.type)); Logger::Error(Game::ERR_FATAL, "No interface for type '{}'!", Game::DB_GetXAssetTypeName(asset.type));
} }
} }
@ -357,7 +357,7 @@ namespace Components
} }
else else
{ {
Logger::Error("No interface for type '%s'!", Game::DB_GetXAssetTypeName(asset.type)); Logger::Error(Game::ERR_FATAL, "No interface for type '{}'!", Game::DB_GetXAssetTypeName(asset.type));
} }
} }
@ -520,8 +520,7 @@ namespace Components
{ {
for (auto& asset : AssetHandler::EmptyAssets) for (auto& asset : AssetHandler::EmptyAssets)
{ {
Game::Com_PrintWarning(Game::conChannel_t::CON_CHANNEL_FILES, Logger::Warning(Game::CON_CHANNEL_FILES, "Could not load {} \"{}\".\n", Game::DB_GetXAssetTypeName(asset.first), asset.second);
reinterpret_cast<const char*>(0x724428), Game::DB_GetXAssetTypeName(asset.first), asset.second.data());
} }
AssetHandler::EmptyAssets.clear(); AssetHandler::EmptyAssets.clear();

View File

@ -19,13 +19,13 @@ namespace Assets
__int64 magic = reader.read<__int64>(); __int64 magic = reader.read<__int64>();
if (std::memcmp(&magic, "IW4xComW", 8)) if (std::memcmp(&magic, "IW4xComW", 8))
{ {
Components::Logger::Error("Reading comworld '%s' failed, header is invalid!", name.data()); Components::Logger::Error(Game::ERR_FATAL, "Reading comworld '{}' failed, header is invalid!", name);
} }
int version = reader.read<int>(); int version = reader.read<int>();
if (version != IW4X_COMMAP_VERSION) if (version != IW4X_COMMAP_VERSION)
{ {
Components::Logger::Error("Reading comworld '%s' failed, expected version is %d, but it was %d!", name.data(), IW4X_COMMAP_VERSION, version); Components::Logger::Error(Game::ERR_FATAL, "Reading comworld '{}' failed, expected version is {}, but it was {}!", name, IW4X_COMMAP_VERSION, version);
} }
Game::ComWorld* asset = reader.readObject<Game::ComWorld>(); Game::ComWorld* asset = reader.readObject<Game::ComWorld>();

View File

@ -104,13 +104,13 @@ namespace Assets
if (!errors.empty()) if (!errors.empty())
{ {
Components::Logger::Error("Font define %s is broken: %s.", name.data(), errors.data()); Components::Logger::Error(Game::ERR_FATAL, "Font define {} is broken: {}", name, errors);
return; return;
} }
if (!fontDef.is_object()) if (!fontDef.is_object())
{ {
Components::Logger::Error("Font define %s is invaild.", name.data(), errors.data()); Components::Logger::Error(Game::ERR_FATAL, "Font define {} is invalid {}", name, errors);
return; return;
} }
@ -162,7 +162,7 @@ namespace Assets
{ {
if (std::find(charset.begin(), charset.end(), i) == charset.end()) if (std::find(charset.begin(), charset.end(), i) == charset.end())
{ {
Components::Logger::Error("Font %s missing codepoint %d.", name.data(), i); Components::Logger::Error(Game::ERR_FATAL, "Font {} missing codepoint {}", name.data(), i);
} }
} }
} }
@ -186,15 +186,15 @@ namespace Assets
if (result == -1) if (result == -1)
{ {
Components::Logger::Error("Truetype font %s is broken.", name.data()); Components::Logger::Error(Game::ERR_FATAL, "Truetype font {} is broken", name);
} }
else if (result < 0) else if (result < 0)
{ {
Components::Logger::Error("Texture size of font %s is not enough.", name.data()); Components::Logger::Error(Game::ERR_FATAL, "Texture size of font {} is not enough", name);
} }
else if(h - result > size) else if(h - result > size)
{ {
Components::Logger::Print("Warn: Texture of font %s have too much left over space: %d\n", name.data(), h - result); Components::Logger::Warning(Game::CON_CHANNEL_DONT_FILTER, "Texture of font {} have too much left over space: {}\n", name, h - result);
} }
header->font = font; header->font = font;

View File

@ -72,13 +72,13 @@ namespace Assets
__int64 magic = buffer.read<__int64>(); __int64 magic = buffer.read<__int64>();
if (std::memcmp(&magic, "IW4xFx ", 8)) if (std::memcmp(&magic, "IW4xFx ", 8))
{ {
Components::Logger::Error("Reading fx '%s' failed, header is invalid!", name.data()); Components::Logger::Error(Game::ERR_FATAL, "Reading fx '{}' failed, header is invalid!", name);
} }
int version = buffer.read<int>(); int version = buffer.read<int>();
if (version != IW4X_FX_VERSION) if (version != IW4X_FX_VERSION)
{ {
Components::Logger::Error("Reading fx '%s' failed, expected version is %d, but it was %d!", name.data(), IW4X_FX_VERSION, version); Components::Logger::Error(Game::ERR_FATAL, "Reading fx '{}' failed, expected version is {}, but it was {}!", name, IW4X_FX_VERSION, version);
} }
Game::FxEffectDef* asset = buffer.readObject<Game::FxEffectDef>(); Game::FxEffectDef* asset = buffer.readObject<Game::FxEffectDef>();
@ -188,7 +188,7 @@ namespace Assets
} }
else if (elemDef->extended.trailDef) else if (elemDef->extended.trailDef)
{ {
Components::Logger::Error("Fx element of type %d has traildef, that's impossible?\n", elemDef->elemType); Components::Logger::Error(Game::ERR_FATAL, "Fx element of type {} has traildef, that's impossible?\n", elemDef->elemType);
} }
} }
} }
@ -211,14 +211,14 @@ namespace Assets
if (format != "iwfx"s) if (format != "iwfx"s)
{ {
Game::Com_EndParseSession(); Game::Com_EndParseSession();
Components::Logger::Error("Effect needs to be updated from the legacy format.\n"); Components::Logger::Error(Game::ERR_FATAL, "Effect needs to be updated from the legacy format.\n");
} }
int version = atoi(Game::Com_Parse(&session)); int version = atoi(Game::Com_Parse(&session));
if (version > 2) if (version > 2)
{ {
Game::Com_EndParseSession(); Game::Com_EndParseSession();
Components::Logger::Error("Version %i is too high. I can only handle up to %i.\n", version, 2); Components::Logger::Error(Game::ERR_FATAL, "Version {} is too high. I can only handle up to 2.\n", version);
} }
Utils::Memory::Allocator allocator; Utils::Memory::Allocator allocator;
@ -231,12 +231,12 @@ namespace Assets
if (!value) break; if (!value) break;
if (*value != '{') if (*value != '{')
{ {
Components::Logger::Error("Expected '{' to start a new segment, found '%s' instead.\n", value); Components::Logger::Error(Game::ERR_FATAL, "Expected '{' to start a new segment, found '{}' instead.\n", value);
} }
if (efx->elemCount >= ARRAYSIZE(efx->elems)) if (efx->elemCount >= ARRAYSIZE(efx->elems))
{ {
Components::Logger::Error("Cannot have more than %i segments.\n", ARRAYSIZE(efx->elems)); Components::Logger::Error(Game::ERR_FATAL, "Cannot have more than {} segments.\n", ARRAYSIZE(efx->elems));
} }
Game::FxEditorElemDef* element = &efx->elems[efx->elemCount]; Game::FxEditorElemDef* element = &efx->elems[efx->elemCount];
@ -253,13 +253,13 @@ namespace Assets
{ {
// TODO: Allow loading assets from raw! // TODO: Allow loading assets from raw!
if (Game::s_elemFields[i].handler(&session, element)) break; if (Game::s_elemFields[i].handler(&session, element)) break;
Components::Logger::Error("Failed to parse element %s!\n", newValue.data()); Components::Logger::Error(Game::ERR_FATAL, "Failed to parse element {}!\n", newValue);
} }
} }
if (!Game::Com_MatchToken(&session, ";", 1)) if (!Game::Com_MatchToken(&session, ";", 1))
{ {
Components::Logger::Error("Expected token ';'\n"); Components::Logger::Error(Game::ERR_FATAL, "Expected token ';'\n");
} }
} }
} }

View File

@ -184,11 +184,12 @@ namespace Assets
} }
} }
} }
void IFxWorld::load(Game::XAssetHeader* /*header*/, const std::string& name, Components::ZoneBuilder::Zone* /*builder*/) void IFxWorld::load(Game::XAssetHeader* /*header*/, const std::string& name, Components::ZoneBuilder::Zone* /*builder*/)
{ {
Game::FxWorld* map = Game::DB_FindXAssetHeader(Game::XAssetType::ASSET_TYPE_FXWORLD, name.data()).fxWorld; Game::FxWorld* map = Game::DB_FindXAssetHeader(Game::XAssetType::ASSET_TYPE_FXWORLD, name.data()).fxWorld;
if (map) return; if (map) return;
Components::Logger::Error("Missing fx_map %s... you can't make them yet you idiot.", name.data()); Components::Logger::Error(Game::ERR_FATAL, "Missing fx_map {}... you can't make them yet you idiot.", name);
} }
} }

View File

@ -12,7 +12,7 @@ namespace Assets
image = builder->getAllocator()->allocate<Game::GfxImage>(); image = builder->getAllocator()->allocate<Game::GfxImage>();
if (!image) if (!image)
{ {
Components::Logger::Error("Failed to allocate GfxImage structure!"); Components::Logger::Error(Game::ERR_FATAL, "Failed to allocate GfxImage structure!");
return; return;
} }
@ -30,7 +30,7 @@ namespace Assets
__int64 magic = reader.read<__int64>(); __int64 magic = reader.read<__int64>();
if (std::memcmp(&magic, "IW4xImg" IW4X_IMG_VERSION, 8)) if (std::memcmp(&magic, "IW4xImg" IW4X_IMG_VERSION, 8))
{ {
Components::Logger::Error(0, "Reading image '%s' failed, header is invalid!", name.data()); Components::Logger::Error(Game::ERR_FATAL, "Reading image '{}' failed, header is invalid!", name);
} }
image->mapType = reader.read<char>(); image->mapType = reader.read<char>();
@ -53,7 +53,7 @@ namespace Assets
if (image->texture.loadDef->resourceSize != dataLength) if (image->texture.loadDef->resourceSize != dataLength)
{ {
Components::Logger::Error("Resource size doesn't match the data length (%s)!\n", name.data()); Components::Logger::Error(Game::ERR_FATAL, "Resource size doesn't match the data length ({})!\n", name);
} }
image->width = loadDef.dimensions[0]; image->width = loadDef.dimensions[0];
@ -72,7 +72,7 @@ namespace Assets
if (!iwi.exists()) if (!iwi.exists())
{ {
Components::Logger::Error("Loading image '%s' failed!", iwi.getName().data()); Components::Logger::Error(Game::ERR_FATAL, "Loading image '{}' failed!", iwi.getName());
return; return;
} }
@ -82,7 +82,7 @@ namespace Assets
if (std::memcmp(iwiHeader->tag, "IWi", 3) && iwiHeader->version == 8) if (std::memcmp(iwiHeader->tag, "IWi", 3) && iwiHeader->version == 8)
{ {
Components::Logger::Error("Image is not a valid IWi!"); Components::Logger::Error(Game::ERR_FATAL, "Image is not a valid IWi!");
return; return;
} }
@ -93,7 +93,7 @@ namespace Assets
image->texture.loadDef = builder->getAllocator()->allocate<Game::GfxImageLoadDef>(); image->texture.loadDef = builder->getAllocator()->allocate<Game::GfxImageLoadDef>();
if (!image->texture.loadDef) if (!image->texture.loadDef)
{ {
Components::Logger::Error("Failed to allocate GfxImageLoadDef structure!"); Components::Logger::Error(Game::ERR_FATAL, "Failed to allocate GfxImageLoadDef structure!");
return; return;
} }

View File

@ -15,14 +15,14 @@ namespace Assets
char* magic = reader.readArray<char>(7); char* magic = reader.readArray<char>(7);
if (std::memcmp(magic, "IW4xLit", 7)) if (std::memcmp(magic, "IW4xLit", 7))
{ {
Components::Logger::Error(0, "Reading light '%s' failed, header is invalid!", name.data()); Components::Logger::Error(Game::ERR_FATAL, "Reading light '{}' failed, header is invalid!", name);
} }
std::string version; std::string version;
version.push_back(reader.read<char>()); version.push_back(reader.read<char>());
if (version != IW4X_LIGHT_VERSION) if (version != IW4X_LIGHT_VERSION)
{ {
Components::Logger::Error("Reading light '%s' failed, expected version is %d, but it was %d!", name.data(), atoi(IW4X_LIGHT_VERSION), atoi(version.data())); Components::Logger::Error(Game::ERR_FATAL, "Reading light '{}' failed, expected version is {}, but it was {}!", name, IW4X_LIGHT_VERSION, version);
} }
Game::GfxLightDef* asset = reader.readObject<Game::GfxLightDef>(); Game::GfxLightDef* asset = reader.readObject<Game::GfxLightDef>();

View File

@ -137,13 +137,13 @@ namespace Assets
__int64 magic = reader.read<__int64>(); __int64 magic = reader.read<__int64>();
if (std::memcmp(&magic, "IW4xGfxW", 8)) if (std::memcmp(&magic, "IW4xGfxW", 8))
{ {
Components::Logger::Error("Reading gfxworld '%s' failed, header is invalid!", name.data()); Components::Logger::Error(Game::ERR_FATAL, "Reading gfxworld '{}' failed, header is invalid!", name);
} }
int version = reader.read<int>(); int version = reader.read<int>();
if (version != IW4X_GFXMAP_VERSION) if (version != IW4X_GFXMAP_VERSION)
{ {
Components::Logger::Error("Reading gfxworld '%s' failed, expected version is %d, but it was %d!", name.data(), IW4X_GFXMAP_VERSION, version); Components::Logger::Error(Game::ERR_FATAL, "Reading gfxworld '{}' failed, expected version is {}, but it was {}!", name, IW4X_GFXMAP_VERSION, version);
} }
Game::GfxWorld* asset = reader.readObject<Game::GfxWorld>(); Game::GfxWorld* asset = reader.readObject<Game::GfxWorld>();

View File

@ -29,7 +29,7 @@ namespace Assets
unsigned int chunkIDBuffer = reader.read<unsigned int>(); unsigned int chunkIDBuffer = reader.read<unsigned int>();
if (chunkIDBuffer != 0x46464952) // RIFF if (chunkIDBuffer != 0x46464952) // RIFF
{ {
Components::Logger::Error(0, "Reading sound '%s' failed, header is invalid!", name.data()); Components::Logger::Error(Game::ERR_FATAL, "Reading sound '{}' failed, header is invalid!", name);
return; return;
} }
@ -38,7 +38,7 @@ namespace Assets
unsigned int format = reader.read<unsigned int>(); unsigned int format = reader.read<unsigned int>();
if (format != 0x45564157) // WAVE if (format != 0x45564157) // WAVE
{ {
Components::Logger::Error(0, "Reading sound '%s' failed, header is invalid!", name.data()); Components::Logger::Error(Game::ERR_FATAL, "Reading sound '{}' failed, header is invalid!", name);
return; return;
} }
@ -55,7 +55,7 @@ namespace Assets
sound->sound.info.format = reader.read<short>(); sound->sound.info.format = reader.read<short>();
if (sound->sound.info.format != 1 && sound->sound.info.format != 17) if (sound->sound.info.format != 1 && sound->sound.info.format != 17)
{ {
Components::Logger::Error(0, "Reading sound '%s' failed, invalid format!", name.data()); Components::Logger::Error(Game::ERR_FATAL, "Reading sound '{}' failed, invalid format!", name);
return; return;
} }
@ -89,11 +89,11 @@ namespace Assets
if (!sound->sound.info.data_ptr) if (!sound->sound.info.data_ptr)
{ {
Components::Logger::Error(0, "Reading sound '%s' failed, invalid format!", name.data()); Components::Logger::Error(Game::ERR_FATAL, "Reading sound '{}' failed, invalid format!", name);
return; return;
} }
sound->name = builder->getAllocator()->duplicateString(name.c_str()); sound->name = builder->getAllocator()->duplicateString(name.data());
header->loadSnd = sound; header->loadSnd = sound;
} }

View File

@ -64,14 +64,14 @@ namespace Assets
char* magic = reader.readArray<char>(7); char* magic = reader.readArray<char>(7);
if (std::memcmp(magic, "IW4xMat", 7)) if (std::memcmp(magic, "IW4xMat", 7))
{ {
Components::Logger::Error(0, "Reading material '%s' failed, header is invalid!", name.data()); Components::Logger::Error(Game::ERR_FATAL, "Reading material '{}' failed, header is invalid!", name);
} }
std::string version; std::string version;
version.push_back(reader.read<char>()); version.push_back(reader.read<char>());
if (version != IW4X_MAT_VERSION) if (version != IW4X_MAT_VERSION)
{ {
Components::Logger::Error("Reading material '%s' failed, expected version is %d, but it was %d!", name.data(), atoi(IW4X_MAT_VERSION), atoi(version.data())); Components::Logger::Error(Game::ERR_FATAL, "Reading material '{}' failed, expected version is {}, but it was {}!", name, IW4X_MAT_VERSION, version);
} }
Game::Material* asset = reader.readObject<Game::Material>(); Game::Material* asset = reader.readObject<Game::Material>();
@ -106,18 +106,18 @@ namespace Assets
asset->techniqueSet = techsetPtr; asset->techniqueSet = techsetPtr;
if (asset->techniqueSet->name[0] == ',') continue; // Try to find a better one if (asset->techniqueSet->name[0] == ',') continue; // Try to find a better one
Components::Logger::Print("Techset '%s' has been mapped to '%s'\n", techsetName.data(), asset->techniqueSet->name); Components::Logger::Print("Techset '{}' has been mapped to '{}'\n", techsetName, asset->techniqueSet->name);
break; break;
} }
} }
} }
else { else {
Components::Logger::Print("Techset %s exists with the same name in iw4, and was mapped 1:1 with %s\n", techsetName.data(), asset->techniqueSet->name); Components::Logger::Print("Techset {} exists with the same name in iw4, and was mapped 1:1 with %s\n", techsetName, asset->techniqueSet->name);
} }
if (!asset->techniqueSet) if (!asset->techniqueSet)
{ {
Components::Logger::Error("Missing techset: '%s' not found", techsetName.data()); Components::Logger::Error(Game::ERR_FATAL, "Missing techset: '{}' not found", techsetName);
} }
} }
@ -195,7 +195,7 @@ namespace Assets
std::memcpy(asset->stateBitsEntry, header.material->stateBitsEntry, 48); std::memcpy(asset->stateBitsEntry, header.material->stateBitsEntry, 48);
asset->constantCount = header.material->constantCount; asset->constantCount = header.material->constantCount;
asset->constantTable = header.material->constantTable; asset->constantTable = header.material->constantTable;
Components::Logger::Print("For %s, copied constants & statebits from %s\n", asset->info.name, header.material->info.name); Components::Logger::Print("For {}, copied constants & statebits from {}\n", asset->info.name, header.material->info.name);
replacementFound = true; replacementFound = true;
} }
} }
@ -231,7 +231,7 @@ namespace Assets
if (techsetMatches(header.material, asset)) if (techsetMatches(header.material, asset))
{ {
Components::Logger::Print("Material %s with techset %s has been mapped to %s\n", asset->info.name, asset->techniqueSet->name, header.material->techniqueSet->name); Components::Logger::Print("Material {} with techset {} has been mapped to {}\n", asset->info.name, asset->techniqueSet->name, header.material->techniqueSet->name);
asset->info.sortKey = header.material->info.sortKey; asset->info.sortKey = header.material->info.sortKey;
replacementFound = true; replacementFound = true;
} }
@ -241,7 +241,7 @@ namespace Assets
if (!replacementFound && asset->techniqueSet) if (!replacementFound && asset->techniqueSet)
{ {
Components::Logger::Print("No replacement found for material %s with techset %s\n", asset->info.name, asset->techniqueSet->name); Components::Logger::Print("No replacement found for material {} with techset {}\n", asset->info.name, asset->techniqueSet->name);
std::string techName = asset->techniqueSet->name; std::string techName = asset->techniqueSet->name;
if (techSetCorrespondance.contains(techName)) if (techSetCorrespondance.contains(techName))
{ {
@ -258,9 +258,8 @@ namespace Assets
if (header.material->techniqueSet == iw4TechSet->asset.header.techniqueSet) if (header.material->techniqueSet == iw4TechSet->asset.header.techniqueSet)
{ {
Components::Logger::Print("Material %s with techset %s has been mapped to %s (last chance!), taking the sort key of material %s\n", Components::Logger::Print("Material {} with techset {} has been mapped to {} (last chance!), taking the sort key of material {}\n",
asset->info.name, asset->techniqueSet->name, asset->info.name, asset->techniqueSet->name, header.material->techniqueSet->name, header.material->info.name);
header.material->techniqueSet->name, header.material->info.name);
asset->info.sortKey = header.material->info.sortKey; asset->info.sortKey = header.material->info.sortKey;
asset->techniqueSet = iw4TechSet->asset.header.techniqueSet; asset->techniqueSet = iw4TechSet->asset.header.techniqueSet;
@ -279,23 +278,23 @@ namespace Assets
if (!replacementFound) if (!replacementFound)
{ {
Components::Logger::Print("Could not find any loaded material with techset %s (in replacement of %s), so I cannot set the sortkey for material %s\n", iw4TechSetName.data(), asset->techniqueSet->name, asset->info.name); Components::Logger::Print("Could not find any loaded material with techset {} (in replacement of {}), so I cannot set the sortkey for material {}\n", iw4TechSetName, asset->techniqueSet->name, asset->info.name);
} }
} }
else else
{ {
Components::Logger::Print("Could not find any loaded techset with iw4 name %s for iw3 techset %s\n", iw4TechSetName.data(), asset->techniqueSet->name); Components::Logger::Print("Could not find any loaded techset with iw4 name {} for iw3 techset {}\n", iw4TechSetName, asset->techniqueSet->name);
} }
} }
else else
{ {
Components::Logger::Print("Could not match iw3 techset %s with any of the techsets I know! This is a critical error, there's a good chance the map will not be playable.\n", techName.data()); Components::Logger::Print("Could not match iw3 techset {} with any of the techsets I know! This is a critical error, there's a good chance the map will not be playable.\n", techName);
} }
} }
if (!reader.end()) if (!reader.end())
{ {
Components::Logger::Error("Material data left!"); Components::Logger::Error(Game::ERR_FATAL, "Material data left!");
} }
/*char baseIndex = 0; /*char baseIndex = 0;
@ -340,7 +339,7 @@ namespace Assets
if (!infoData.is_object()) if (!infoData.is_object())
{ {
Components::Logger::Error("Failed to load material information for %s!", name.data()); Components::Logger::Error(Game::ERR_FATAL, "Failed to load material information for {}!", name);
return; return;
} }
@ -348,7 +347,7 @@ namespace Assets
if (!base.is_string()) if (!base.is_string())
{ {
Components::Logger::Error("No valid material base provided for %s!", name.data()); Components::Logger::Error(Game::ERR_FATAL, "No valid material base provided for {}!", name);
return; return;
} }
@ -356,7 +355,7 @@ namespace Assets
if (!baseMaterial) // TODO: Maybe check if default asset? Maybe not? You could still want to use the default one as base!? if (!baseMaterial) // TODO: Maybe check if default asset? Maybe not? You could still want to use the default one as base!?
{ {
Components::Logger::Error("Basematerial '%s' not found for %s!", base.string_value().data(), name.data()); Components::Logger::Error(Game::ERR_FATAL, "Basematerial '{}' not found for {}!", base.string_value(), name);
return; return;
} }
@ -364,7 +363,7 @@ namespace Assets
if (!material) if (!material)
{ {
Components::Logger::Error("Failed to allocate material structure!"); Components::Logger::Error(Game::ERR_FATAL, "Failed to allocate material structure!");
return; return;
} }
@ -452,7 +451,8 @@ namespace Assets
if (!applied) if (!applied)
{ {
Components::Logger::Error(0, "Unable to find texture for map '%s' in %s!", map.string_value().data(), baseMaterial->info.name); Components::Logger::Error(Game::ERR_FATAL, "Unable to find texture for map '{}' in {}!",
map.string_value(), baseMaterial->info.name);
} }
} }
else else
@ -469,7 +469,7 @@ namespace Assets
if (!textureTable) if (!textureTable)
{ {
Components::Logger::Error("Failed to allocate texture table!"); Components::Logger::Error(Game::ERR_FATAL, "Failed to allocate texture table!");
return; return;
} }

View File

@ -26,14 +26,15 @@ namespace Assets
char* magic = reader.readArray<char>(8); char* magic = reader.readArray<char>(8);
if (std::memcmp(magic, "IW4xPIXL", 8)) if (std::memcmp(magic, "IW4xPIXL", 8))
{ {
Components::Logger::Error(0, "Reading pixel shader '%s' failed, header is invalid!", name.data()); Components::Logger::Error(Game::ERR_FATAL, "Reading pixel shader '{}' failed, header is invalid!", name);
} }
std::string version; std::string version;
version.push_back(reader.read<char>()); version.push_back(reader.read<char>());
if (version != IW4X_TECHSET_VERSION) if (version != IW4X_TECHSET_VERSION)
{ {
Components::Logger::Error("Reading pixel shader '%s' failed, expected version is %d, but it was %d!", name.data(), atoi(IW4X_TECHSET_VERSION), atoi(version.data())); Components::Logger::Error(Game::ERR_FATAL,
"Reading pixel shader '{}' failed, expected version is {}, but it was {}!", name, IW4X_TECHSET_VERSION, version);
} }
Game::MaterialPixelShader* asset = reader.readObject<Game::MaterialPixelShader>(); Game::MaterialPixelShader* asset = reader.readObject<Game::MaterialPixelShader>();

View File

@ -22,7 +22,7 @@ namespace Assets
Components::FileSystem::File techFile(Utils::String::VA("techniques/%s.iw4xTech", name.data())); Components::FileSystem::File techFile(Utils::String::VA("techniques/%s.iw4xTech", name.data()));
if (!techFile.exists()) { if (!techFile.exists()) {
*tech = nullptr; *tech = nullptr;
Components::Logger::Print("Warning: Missing technique '%s'\n", name.data()); Components::Logger::Warning(Game::CON_CHANNEL_DONT_FILTER, "Missing technique '{}'\n", name);
return; return;
} }
@ -31,14 +31,15 @@ namespace Assets
char* magic = reader.readArray<char>(8); char* magic = reader.readArray<char>(8);
if (std::memcmp(magic, "IW4xTECH", 8)) if (std::memcmp(magic, "IW4xTECH", 8))
{ {
Components::Logger::Error(0, "Reading technique '%s' failed, header is invalid!", name.data()); Components::Logger::Error(Game::ERR_FATAL, "Reading technique '{}' failed, header is invalid!", name);
} }
std::string version; std::string version;
version.push_back(reader.read<char>()); version.push_back(reader.read<char>());
if (version != IW4X_TECHSET_VERSION) if (version != IW4X_TECHSET_VERSION)
{ {
Components::Logger::Error("Reading technique '%s' failed, expected version is %d, but it was %d!", name.data(), atoi(IW4X_TECHSET_VERSION), atoi(version.data())); Components::Logger::Error(Game::ERR_FATAL,
"Reading technique '{}' failed, expected version is {}, but it was {}!", name, IW4X_TECHSET_VERSION, version.data());
} }
unsigned short flags = reader.read<unsigned short>(); unsigned short flags = reader.read<unsigned short>();
@ -107,14 +108,15 @@ namespace Assets
char* magic = reader.readArray<char>(8); char* magic = reader.readArray<char>(8);
if (std::memcmp(magic, "IW4xTSET", 8)) if (std::memcmp(magic, "IW4xTSET", 8))
{ {
Components::Logger::Error(0, "Reading techset '%s' failed, header is invalid!", name.data()); Components::Logger::Error(Game::ERR_FATAL, "Reading techset '{}' failed, header is invalid!", name);
} }
std::string version; std::string version;
version.push_back(reader.read<char>()); version.push_back(reader.read<char>());
if (version != IW4X_TECHSET_VERSION) if (version != IW4X_TECHSET_VERSION)
{ {
Components::Logger::Error("Reading techset '%s' failed, expected version is %d, but it was %d!", name.data(), atoi(IW4X_TECHSET_VERSION), atoi(version.data())); Components::Logger::Error(Game::ERR_FATAL, "Reading techset '{}' failed, expected version is {}, but it was {}!",
name, IW4X_TECHSET_VERSION, version);
} }
Game::MaterialTechniqueSet* asset = reader.readObject<Game::MaterialTechniqueSet>(); Game::MaterialTechniqueSet* asset = reader.readObject<Game::MaterialTechniqueSet>();

View File

@ -25,14 +25,15 @@ namespace Assets
char* magic = reader.readArray<char>(8); char* magic = reader.readArray<char>(8);
if (std::memcmp(magic, "IW4xDECL", 8)) if (std::memcmp(magic, "IW4xDECL", 8))
{ {
Components::Logger::Error(0, "Reading vertex declaration '%s' failed, header is invalid!", name.data()); Components::Logger::Error(Game::ERR_FATAL, "Reading vertex declaration '{}' failed, header is invalid!", name);
} }
std::string version; std::string version;
version.push_back(reader.read<char>()); version.push_back(reader.read<char>());
if (version != IW4X_TECHSET_VERSION) if (version != IW4X_TECHSET_VERSION)
{ {
Components::Logger::Error("Reading vertex declaration '%s' failed, expected version is %d, but it was %d!", name.data(), atoi(IW4X_TECHSET_VERSION), atoi(version.data())); Components::Logger::Error(Game::ERR_FATAL, "Reading vertex declaration '{}' failed, expected version is {}, but it was {}!",
name, IW4X_TECHSET_VERSION, version.data());
} }
Game::MaterialVertexDeclaration* asset = reader.readObject<Game::MaterialVertexDeclaration>(); Game::MaterialVertexDeclaration* asset = reader.readObject<Game::MaterialVertexDeclaration>();

View File

@ -25,14 +25,15 @@ namespace Assets
char* magic = reader.readArray<char>(8); char* magic = reader.readArray<char>(8);
if (std::memcmp(magic, "IW4xVERT", 8)) if (std::memcmp(magic, "IW4xVERT", 8))
{ {
Components::Logger::Error(0, "Reading vertex shader '%s' failed, header is invalid!", name.data()); Components::Logger::Error(Game::ERR_FATAL, "Reading vertex shader '{}' failed, header is invalid!", name);
} }
std::string version; std::string version;
version.push_back(reader.read<char>()); version.push_back(reader.read<char>());
if (version != IW4X_TECHSET_VERSION) if (version != IW4X_TECHSET_VERSION)
{ {
Components::Logger::Error("Reading vertex shader '%s' failed, expected version is %d, but it was %d!", name.data(), atoi(IW4X_TECHSET_VERSION), atoi(version.data())); Components::Logger::Error(Game::ERR_FATAL, "Reading vertex shader '{}' failed, expected version is {}, but it was {}!",
name, IW4X_TECHSET_VERSION, version);
} }
Game::MaterialVertexShader* asset = reader.readObject<Game::MaterialVertexShader>(); Game::MaterialVertexShader* asset = reader.readObject<Game::MaterialVertexShader>();

View File

@ -15,13 +15,13 @@ namespace Assets
__int64 magic = reader.read<__int64>(); __int64 magic = reader.read<__int64>();
if (std::memcmp(&magic, "IW4xAnim", 8)) if (std::memcmp(&magic, "IW4xAnim", 8))
{ {
Components::Logger::Error(0, "Reading animation '%s' failed, header is invalid!", name.data()); Components::Logger::Error(Game::ERR_FATAL, "Reading animation '{}' failed, header is invalid!", name);
} }
int version = reader.read<int>(); int version = reader.read<int>();
if (version != IW4X_ANIM_VERSION) if (version != IW4X_ANIM_VERSION)
{ {
Components::Logger::Error(0, "Reading animation '%s' failed, expected version is %d, but it was %d!", name.data(), IW4X_ANIM_VERSION, version); Components::Logger::Error(Game::ERR_FATAL, "Reading animation '{}' failed, expected version is {}, but it was {}!", name, IW4X_ANIM_VERSION, version);
} }
Game::XAnimParts* xanim = reader.readArray<Game::XAnimParts>(); Game::XAnimParts* xanim = reader.readArray<Game::XAnimParts>();
@ -96,7 +96,7 @@ namespace Assets
if (!reader.end()) if (!reader.end())
{ {
Components::Logger::Error(0, "Reading animation '%s' failed, remaining raw data found!", name.data()); Components::Logger::Error(Game::ERR_FATAL, "Reading animation '{}' failed, remaining raw data found!", name);
} }
header->parts = xanim; header->parts = xanim;

View File

@ -100,18 +100,18 @@ namespace Assets
__int64 magic = reader.read<__int64>(); __int64 magic = reader.read<__int64>();
if (std::memcmp(&magic, "IW4xModl", 8)) if (std::memcmp(&magic, "IW4xModl", 8))
{ {
Components::Logger::Error(0, "Reading model '%s' failed, header is invalid!", name.data()); Components::Logger::Error(Game::ERR_FATAL, "Reading model '{}' failed, header is invalid!", name);
} }
int version = reader.read<int>(); int version = reader.read<int>();
if (version != IW4X_MODEL_VERSION) if (version != IW4X_MODEL_VERSION)
{ {
Components::Logger::Error(0, "Reading model '%s' failed, expected version is %d, but it was %d!", name.data(), IW4X_MODEL_VERSION, version); Components::Logger::Error(Game::ERR_FATAL, "Reading model '{}' failed, expected version is {}, but it was {}!", name, IW4X_MODEL_VERSION, version);
} }
if (version == 4) if (version == 4)
{ {
Components::Logger::Print("WARNING: Model '%s' is in legacy format, please update it!\n", name.data()); Components::Logger::Warning(Game::CON_CHANNEL_DONT_FILTER, "Model '{}' is in legacy format, please update it!\n", name);
} }
Game::XModel* asset = reader.readObject<Game::XModel>(); Game::XModel* asset = reader.readObject<Game::XModel>();
@ -310,7 +310,7 @@ namespace Assets
if (!reader.end()) if (!reader.end())
{ {
Components::Logger::Error(0, "Reading model '%s' failed, remaining raw data found!", name.data()); Components::Logger::Error(Game::ERR_FATAL, "Reading model '{}' failed, remaining raw data found!", name);
} }
header->model = asset; header->model = asset;

View File

@ -601,13 +601,13 @@ namespace Assets
__int64 magic = reader.read<__int64>(); __int64 magic = reader.read<__int64>();
if (std::memcmp(&magic, "IW4xClip", 8)) if (std::memcmp(&magic, "IW4xClip", 8))
{ {
Components::Logger::Error(0, "Reading clipMap_t '%s' failed, header is invalid!", name.data()); Components::Logger::Error(Game::ERR_FATAL, "Reading clipMap_t '{}' failed, header is invalid!", name);
} }
int version = reader.read<int>(); int version = reader.read<int>();
if (version > IW4X_CLIPMAP_VERSION) if (version > IW4X_CLIPMAP_VERSION)
{ {
Components::Logger::Error(0, "Reading clipmap '%s' failed, expected version is %d, but it was %d!", name.data(), IW4X_CLIPMAP_VERSION, version); Components::Logger::Error(Game::ERR_FATAL, "Reading clipmap '{}' failed, expected version is {}, but it was {}!", name, IW4X_CLIPMAP_VERSION, version);
} }
clipMap->name = reader.readCString(); clipMap->name = reader.readCString();
@ -682,7 +682,7 @@ namespace Assets
int planeIndex = reader.read<int>(); int planeIndex = reader.read<int>();
if (planeIndex < 0 || planeIndex >= clipMap->planeCount) if (planeIndex < 0 || planeIndex >= clipMap->planeCount)
{ {
Components::Logger::Error("invalid plane index"); Components::Logger::Error(Game::ERR_FATAL, "invalid plane index");
return; return;
} }
clipMap->brushsides[i].plane = &clipMap->planes[planeIndex]; clipMap->brushsides[i].plane = &clipMap->planes[planeIndex];
@ -705,7 +705,7 @@ namespace Assets
int planeIndex = reader.read<int>(); int planeIndex = reader.read<int>();
if (planeIndex < 0 || planeIndex >= clipMap->planeCount) if (planeIndex < 0 || planeIndex >= clipMap->planeCount)
{ {
Components::Logger::Error("invalid plane index\n"); Components::Logger::Error(Game::ERR_FATAL, "invalid plane index\n");
return; return;
} }
clipMap->nodes[i].plane = &clipMap->planes[planeIndex]; clipMap->nodes[i].plane = &clipMap->planes[planeIndex];
@ -773,7 +773,7 @@ namespace Assets
int index = reader.read<int>(); int index = reader.read<int>();
if (index < 0 || index > clipMap->borderCount) if (index < 0 || index > clipMap->borderCount)
{ {
Components::Logger::Error("invalid border index\n"); Components::Logger::Error(Game::ERR_FATAL, "invalid border index\n");
return; return;
} }
clipMap->partitions[i].borders = &clipMap->borders[index]; clipMap->partitions[i].borders = &clipMap->borders[index];
@ -800,10 +800,10 @@ namespace Assets
clipMap->brushes[i].numsides = reader.read<unsigned int>() & 0xFFFF; // todo: check for overflow here clipMap->brushes[i].numsides = reader.read<unsigned int>() & 0xFFFF; // todo: check for overflow here
if (clipMap->brushes[i].numsides > 0) if (clipMap->brushes[i].numsides > 0)
{ {
unsigned int index = reader.read<unsigned int>(); auto index = reader.read<unsigned int>();
if (index < 0 || index > clipMap->numBrushSides) if (index < 0 || index > clipMap->numBrushSides)
{ {
Components::Logger::Error("invalid side index\n"); Components::Logger::Error(Game::ERR_FATAL, "invalid side index\n");
return; return;
} }
clipMap->brushes[i].sides = &clipMap->brushsides[index]; clipMap->brushes[i].sides = &clipMap->brushsides[index];
@ -813,10 +813,10 @@ namespace Assets
clipMap->brushes[i].sides = nullptr; clipMap->brushes[i].sides = nullptr;
} }
unsigned int index = reader.read<unsigned int>(); auto index = reader.read<unsigned int>();
if (index > clipMap->numBrushEdges) if (index > clipMap->numBrushEdges)
{ {
Components::Logger::Error("invalid edge index\n"); Components::Logger::Error(Game::ERR_FATAL, "invalid edge index\n");
return; return;
} }
clipMap->brushes[i].baseAdjacentSide = &clipMap->brushEdges[index]; clipMap->brushes[i].baseAdjacentSide = &clipMap->brushEdges[index];
@ -935,7 +935,7 @@ namespace Assets
if (!reader.end()) if (!reader.end())
{ {
Components::Logger::Error("Clipmap data left!"); Components::Logger::Error(Game::ERR_FATAL, "Clipmap data left!");
} }
header->clipMap = clipMap; header->clipMap = clipMap;

View File

@ -11,7 +11,7 @@ namespace Assets
auto menus = Components::Menus::LoadMenu(Utils::String::VA("ui_mp/%s.menu", name.data())); auto menus = Components::Menus::LoadMenu(Utils::String::VA("ui_mp/%s.menu", name.data()));
if (menus.size() == 0) return; if (menus.size() == 0) return;
if (menus.size() > 1) Components::Logger::Print("Menu '%s' on disk has more than one menudef in it. Only saving the first one\n", name.data()); if (menus.size() > 1) Components::Logger::Print("Menu '{}' on disk has more than one menudef in it. Only saving the first one\n", name);
header->menu = menus[0].second; header->menu = menus[0].second;
} }

View File

@ -42,7 +42,7 @@ namespace Assets
if (!infoData.is_object()) if (!infoData.is_object())
{ {
Components::Logger::Error("Failed to load sound %s!", name.c_str()); Components::Logger::Error(Game::ERR_FATAL, "Failed to load sound {}!", name);
return; return;
} }
@ -86,14 +86,14 @@ namespace Assets
{ {
soundFile = head["soundfile"]; soundFile = head["soundfile"];
Components::Logger::Print("Fixed casing on %s\n", name.c_str()); Components::Logger::Print("Fixed casing on {}\n", name);
} }
if (type.is_null() || soundFile.is_null()) if (type.is_null() || soundFile.is_null())
{ {
Components::Logger::Print("Type is %s\n", type.dump().c_str()); Components::Logger::Print("Type is {}\n", type.dump());
Components::Logger::Print("SoundFile is %s\n", soundFile.dump().c_str()); Components::Logger::Print("SoundFile is {}\n", soundFile.dump());
Components::Logger::Error("Failed to parse sound %s! Each alias must have at least a type and a soundFile\n", name.c_str()); Components::Logger::Error(Game::ERR_FATAL, "Failed to parse sound {}! Each alias must have at least a type and a soundFile\n", name);
return; return;
} }
@ -102,102 +102,102 @@ namespace Assets
// TODO: actually support all of those properties // TODO: actually support all of those properties
if (!CHECK(type, number)) if (!CHECK(type, number))
{ {
Components::Logger::Print("%s is not number but %d (%s)\n", "type", type.type(), type.dump().c_str()); Components::Logger::Print("{} is not number but {} ({})\n", "type", Utils::Json::TypeToString(type.type()), type.dump());
} }
if (!CHECK(subtitle, string)) if (!CHECK(subtitle, string))
{ {
Components::Logger::Print("%s is not string but %d (%s)\n", "subtitle", subtitle.type(), subtitle.dump().c_str()); Components::Logger::Print("{} is not string but {} ({})\n", "subtitle", Utils::Json::TypeToString(subtitle.type()), subtitle.dump());
} }
if (!CHECK(aliasName, string)) if (!CHECK(aliasName, string))
{ {
Components::Logger::Print("%s is not string but %d (%s)\n", "aliasName", aliasName.type(), aliasName.dump().c_str()); Components::Logger::Print("{} is not string but {} ({})\n", "aliasName", Utils::Json::TypeToString(aliasName.type()), aliasName.dump());
} }
if (!CHECK(secondaryAliasName, string)) if (!CHECK(secondaryAliasName, string))
{ {
Components::Logger::Print("%s is not string but %d (%s)\n", "secondaryAliasName", secondaryAliasName.type(), secondaryAliasName.dump().c_str()); Components::Logger::Print("{} is not string but {} ({})\n", "secondaryAliasName", Utils::Json::TypeToString(secondaryAliasName.type()), secondaryAliasName.dump());
} }
if (!CHECK(chainAliasName, string)) if (!CHECK(chainAliasName, string))
{ {
Components::Logger::Print("%s is not string but %d (%s)\n", "chainAliasName", chainAliasName.type(), chainAliasName.dump().c_str()); Components::Logger::Print("{} is not string but {} ({})\n", "chainAliasName", Utils::Json::TypeToString(chainAliasName.type()), chainAliasName.dump());
} }
if (!CHECK(soundFile, string)) if (!CHECK(soundFile, string))
{ {
Components::Logger::Print("%s is not string but %d (%s)\n", "soundFile", soundFile.type(), soundFile.dump().c_str()); Components::Logger::Print("{} is not string but {} ({})\n", "soundFile", Utils::Json::TypeToString(soundFile.type()), soundFile.dump());
} }
if (!CHECK(sequence, number)) if (!CHECK(sequence, number))
{ {
Components::Logger::Print("%s is not number but %d (%s)\n", "sequence", sequence.type(), sequence.dump().c_str()); Components::Logger::Print("{} is not number but {} ({})\n", "sequence", Utils::Json::TypeToString(sequence.type()), sequence.dump());
} }
if (!CHECK(volMin, number)) if (!CHECK(volMin, number))
{ {
Components::Logger::Print("%s is not number but %d (%s)\n", "volMin", volMin.type(), volMin.dump().c_str()); Components::Logger::Print("{} is not number but {} ({})\n", "volMin", Utils::Json::TypeToString(volMin.type()), volMin.dump());
} }
if (!CHECK(volMax, number)) if (!CHECK(volMax, number))
{ {
Components::Logger::Print("%s is not number but %d (%s)\n", "volMax", volMax.type(), volMax.dump().c_str()); Components::Logger::Print("{} is not number but {} ({})\n", "volMax", Utils::Json::TypeToString(volMax.type()), volMax.dump());
} }
if (!CHECK(pitchMin, number)) if (!CHECK(pitchMin, number))
{ {
Components::Logger::Print("%s is not number but %d (%s)\n", "pitchMin", pitchMin.type(), pitchMin.dump().c_str()); Components::Logger::Print("{} is not number but {} ({})\n", "pitchMin", Utils::Json::TypeToString(pitchMin.type()), pitchMin.dump());
} }
if (!CHECK(pitchMax, number)) if (!CHECK(pitchMax, number))
{ {
Components::Logger::Print("%s is not number but %d (%s)\n", "pitchMax", pitchMax.type(), pitchMax.dump().c_str()); Components::Logger::Print("{} is not number but {} ()\n", "pitchMax", Utils::Json::TypeToString(pitchMax.type()), pitchMax.dump());
} }
if (!CHECK(probability, number)) if (!CHECK(probability, number))
{ {
Components::Logger::Print("%s is not number but %d (%s)\n", "probability", probability.type(), probability.dump().c_str()); Components::Logger::Print("{} is not number but {} ({}))\n", "probability", Utils::Json::TypeToString(probability.type()), probability.dump());
} }
if (!CHECK(lfePercentage, number)) if (!CHECK(lfePercentage, number))
{ {
Components::Logger::Print("%s is not number but %d (%s)\n", "lfePercentage", lfePercentage.type(), lfePercentage.dump().c_str()); Components::Logger::Print("{} is not number but {} ({})\n", "lfePercentage", Utils::Json::TypeToString(lfePercentage.type()), lfePercentage.dump());
} }
if (!CHECK(centerPercentage, number)) if (!CHECK(centerPercentage, number))
{ {
Components::Logger::Print("%s is not number but %d (%s)\n", "centerPercentage", centerPercentage.type(), centerPercentage.dump().c_str()); Components::Logger::Print("{} is not number but {} ({})\n", "centerPercentage", Utils::Json::TypeToString(centerPercentage.type()), centerPercentage.dump());
} }
if (!CHECK(startDelay, number)) if (!CHECK(startDelay, number))
{ {
Components::Logger::Print("%s is not number but %d (%s)\n", "startDelay", startDelay.type(), startDelay.dump().c_str()); Components::Logger::Print("{} is not number but {} ({})\n", "startDelay", Utils::Json::TypeToString(startDelay.type()), startDelay.dump());
} }
if (!CHECK(volumeFalloffCurve, string)) if (!CHECK(volumeFalloffCurve, string))
{ {
Components::Logger::Print("%s is not string but %d (%s)\n", "volumeFalloffCurve", volumeFalloffCurve.type(), volumeFalloffCurve.dump().c_str()); Components::Logger::Print("{}s is not string but {} ({})\n", "volumeFalloffCurve", Utils::Json::TypeToString(volumeFalloffCurve.type()), volumeFalloffCurve.dump());
} }
if (!CHECK(envelopMin, number)) if (!CHECK(envelopMin, number))
{ {
Components::Logger::Print("%s is not number but %d (%s)\n", "envelopMin", envelopMin.type(), envelopMin.dump().c_str()); Components::Logger::Print("{} is not number but {} ({})\n", "envelopMin", Utils::Json::TypeToString(envelopMin.type()), envelopMin.dump());
} }
if (!CHECK(envelopMax, number)) if (!CHECK(envelopMax, number))
{ {
Components::Logger::Print("%s is not number but %d (%s)\n", "envelopMax", envelopMax.type(), envelopMax.dump().c_str()); Components::Logger::Print("{} is not number but {} ({})\n", "envelopMax", Utils::Json::TypeToString(envelopMax.type()), envelopMax.dump());
} }
if (!CHECK(envelopPercentage, number)) if (!CHECK(envelopPercentage, number))
{ {
Components::Logger::Print("%s is not number but %d (%s)\n", "envelopPercentage", envelopPercentage.type(), envelopPercentage.dump().c_str()); Components::Logger::Print("{} is not number but {} ({})\n", "envelopPercentage", Utils::Json::TypeToString(envelopPercentage.type()), envelopPercentage.dump());
} }
if (!CHECK(speakerMap, object)) if (!CHECK(speakerMap, object))
{ {
Components::Logger::Print("%s is not object but %d (%s)\n", "speakerMap", speakerMap.type(), speakerMap.dump().c_str()); Components::Logger::Print("{} is not object but {} ({})\n", "speakerMap", Utils::Json::TypeToString(speakerMap.type()), speakerMap.dump());
} }
@ -248,7 +248,7 @@ namespace Assets
alias->speakerMap = builder->getAllocator()->allocate<Game::SpeakerMap>(); alias->speakerMap = builder->getAllocator()->allocate<Game::SpeakerMap>();
if (!alias->speakerMap) if (!alias->speakerMap)
{ {
Components::Logger::Print("Error allocating memory for speakermap in sound alias%s!\n", alias->aliasName); Components::Logger::Print("Error allocating memory for speakermap in sound alias{}!\n", alias->aliasName);
return; return;
} }
@ -328,7 +328,7 @@ namespace Assets
} }
else else
{ {
Components::Logger::Error("Failed to parse sound %s! Invalid sound type %s\n", name.c_str(), type.string_value().c_str()); Components::Logger::Error(Game::ERR_FATAL, "Failed to parse sound {}! Invalid sound type {}\n", name, type.string_value());
return; return;
} }
@ -336,7 +336,7 @@ namespace Assets
} }
else else
{ {
Components::Logger::Error("Failed to parse sound %s!\n", name.c_str()); Components::Logger::Error(Game::ERR_FATAL, "Failed to parse sound {}!\n", name);
return; return;
} }
} }

View File

@ -41,7 +41,7 @@ namespace Components
Auth::TokenContainer.generating = false; Auth::TokenContainer.generating = false;
Auth::StoreKey(); Auth::StoreKey();
Logger::Print("Security level is %d\n", Auth::GetSecurityLevel()); Logger::DebugInfo("Security level is %d", Auth::GetSecurityLevel());
Command::Execute("closemenu security_increase_popmenu", false); Command::Execute("closemenu security_increase_popmenu", false);
if (!Auth::TokenContainer.cancel) if (!Auth::TokenContainer.cancel)
@ -67,14 +67,14 @@ namespace Components
Steam::SteamUser()->GetSteamID(); Steam::SteamUser()->GetSteamID();
if (!Auth::GuidKey.isValid()) if (!Auth::GuidKey.isValid())
{ {
Logger::SoftError("Connecting failed: Guid key is invalid!"); Logger::Error(Game::ERR_SERVERDISCONNECT, "Connecting failed: Guid key is invalid!");
return; return;
} }
if (std::find(Auth::BannedUids.begin(), Auth::BannedUids.end(), Steam::SteamUser()->GetSteamID().bits) != Auth::BannedUids.end()) if (std::find(Auth::BannedUids.begin(), Auth::BannedUids.end(), Steam::SteamUser()->GetSteamID().bits) != Auth::BannedUids.end())
{ {
Auth::GenerateKey(); Auth::GenerateKey();
Logger::SoftError("Your online profile is invalid. A new key has been generated."); Logger::Error(Game::ERR_SERVERDISCONNECT, "Your online profile is invalid. A new key has been generated.");
return; return;
} }
@ -86,7 +86,7 @@ namespace Components
if (params.size() < 3) if (params.size() < 3)
{ {
Game::SV_Cmd_EndTokenizedString(); Game::SV_Cmd_EndTokenizedString();
Logger::SoftError("Connecting failed: Command parsing error!"); Logger::Error(Game::ERR_SERVERDISCONNECT, "Connecting failed: Command parsing error!");
return; return;
} }
@ -96,7 +96,7 @@ namespace Components
if (challenge.empty()) if (challenge.empty())
{ {
Game::SV_Cmd_EndTokenizedString(); Game::SV_Cmd_EndTokenizedString();
Logger::SoftError("Connecting failed: Challenge parsing error!"); Logger::Error(Game::ERR_SERVERDISCONNECT, "Connecting failed: Challenge parsing error!");
return; return;
} }
@ -233,7 +233,7 @@ namespace Components
return; return;
} }
Logger::Print("Verified XUID %llX (%d) from %s\n", xuid, userLevel, address.getCString()); Logger::DebugInfo("Verified XUID {:#X} ({}) from {}", xuid, userLevel, address.getCString());
Game::SV_DirectConnect(*address.get()); Game::SV_DirectConnect(*address.get());
} }
#endif #endif
@ -448,7 +448,7 @@ namespace Components
// Guid command // Guid command
Command::Add("guid", [](Command::Params*) Command::Add("guid", [](Command::Params*)
{ {
Logger::Print("Your guid: %llX\n", Steam::SteamUser()->GetSteamID().bits); Logger::Print("Your guid: {:#X}\n", Steam::SteamUser()->GetSteamID().bits);
}); });
if (!Dedicated::IsEnabled() && !ZoneBuilder::IsEnabled()) if (!Dedicated::IsEnabled() && !ZoneBuilder::IsEnabled())
@ -458,9 +458,9 @@ namespace Components
if (params->size() < 2) if (params->size() < 2)
{ {
uint32_t level = Auth::GetZeroBits(Auth::GuidToken, Auth::GuidKey.getPublicKey()); uint32_t level = Auth::GetZeroBits(Auth::GuidToken, Auth::GuidKey.getPublicKey());
Logger::Print("Your current security level is %d\n", level); Logger::Print("Your current security level is {}\n", level);
Logger::Print("Your security token is: %s\n", Utils::String::DumpHex(Auth::GuidToken.toString(), "").data()); Logger::Print("Your security token is: {}\n", Utils::String::DumpHex(Auth::GuidToken.toString(), ""));
Logger::Print("Your computation token is: %s\n", Utils::String::DumpHex(Auth::ComputeToken.toString(), "").data()); Logger::Print("Your computation token is: {}\n", Utils::String::DumpHex(Auth::ComputeToken.toString(), ""));
Toast::Show("cardicon_locked", "^5Security Level", Utils::String::VA("Your security level is %d", level), 3000); Toast::Show("cardicon_locked", "^5Security Level", Utils::String::VA("Your security level is %d", level), 3000);
} }

View File

@ -126,7 +126,7 @@ namespace Components
if (!error.empty()) if (!error.empty())
{ {
Logger::Error("Failed to parse bans (bans.json): %s", error.data()); Logger::Error(Game::ERR_FATAL, "Failed to parse bans (bans.json): {}", error);
} }
if (!list) return; if (!list) return;
@ -176,7 +176,7 @@ namespace Components
if (*Game::svs_clientCount <= num) if (*Game::svs_clientCount <= num)
{ {
Logger::Print("Player %d is not on the server\n", num); Logger::Print("Player {} is not on the server\n", num);
return; return;
} }
@ -253,7 +253,7 @@ namespace Components
Network::Address address(params->get(2)); Network::Address address(params->get(2));
Bans::UnbanClient(address.getIP()); Bans::UnbanClient(address.getIP());
Logger::Print("Unbanned IP %s\n", params->get(2)); Logger::Print("Unbanned IP {}\n", params->get(2));
} }
else if (type == "guid"s) else if (type == "guid"s)
@ -263,7 +263,7 @@ namespace Components
Bans::UnbanClient(id); Bans::UnbanClient(id);
Logger::Print("Unbanned GUID %s\n", params->get(2)); Logger::Print("Unbanned GUID {}\n", params->get(2));
} }
}); });

View File

@ -367,8 +367,7 @@ namespace Components
if (input == end) if (input == end)
{ {
Logger::Print("Warning: %s is not a valid input\n" Logger::Warning(Game::CON_CHANNEL_DONT_FILTER, "{} is not a valid input\nUsage: {} optional <number of bots> or optional <\"all\">\n",
"Usage: %s optional <number of bots> or optional <\"all\">\n",
input, params->get(0)); input, params->get(0));
return; return;
} }
@ -386,7 +385,7 @@ namespace Components
} }
Toast::Show("cardicon_headshot", "^2Success", Utils::String::VA("Spawning %d %s...", count, (count == 1 ? "bot" : "bots")), 3000); Toast::Show("cardicon_headshot", "^2Success", Utils::String::VA("Spawning %d %s...", count, (count == 1 ? "bot" : "bots")), 3000);
Logger::Print("Spawning %d %s...\n", count, (count == 1 ? "bot" : "bots")); Logger::DebugInfo("Spawning {} {}", count, (count == 1 ? "bot" : "bots"));
Bots::Spawn(count); Bots::Spawn(count);
}); });

View File

@ -231,14 +231,14 @@ namespace Components
Chat::MuteList.insert(client->steamID); Chat::MuteList.insert(client->steamID);
lock.unlock(); lock.unlock();
Logger::Print("%s was muted\n", client->name); Logger::Print("{} was muted\n", client->name);
Game::SV_GameSendServerCommand(client->gentity->s.number, Game::SV_CMD_CAN_IGNORE, Game::SV_GameSendServerCommand(client->gentity->s.number, Game::SV_CMD_CAN_IGNORE,
Utils::String::VA("%c \"You were muted\"", 0x65)); Utils::String::VA("%c \"You were muted\"", 0x65));
return; return;
} }
lock.unlock(); lock.unlock();
Logger::Print("%s is already muted\n", client->name); Logger::Print("{} is already muted\n", client->name);
Game::SV_GameSendServerCommand(-1, Game::SV_CMD_CAN_IGNORE, Game::SV_GameSendServerCommand(-1, Game::SV_CMD_CAN_IGNORE,
Utils::String::VA("%c \"%s is already muted\"", 0x65, client->name)); Utils::String::VA("%c \"%s is already muted\"", 0x65, client->name));
} }
@ -247,7 +247,7 @@ namespace Components
{ {
Chat::UnmuteInternal(client->steamID); Chat::UnmuteInternal(client->steamID);
Logger::Print("%s was unmuted\n", client->name); Logger::Print("{} was unmuted\n", client->name);
Game::SV_GameSendServerCommand(client->gentity->s.number, Game::SV_CMD_CAN_IGNORE, Game::SV_GameSendServerCommand(client->gentity->s.number, Game::SV_CMD_CAN_IGNORE,
Utils::String::VA("%c \"You were unmuted\"", 0x65)); Utils::String::VA("%c \"You were unmuted\"", 0x65));
} }
@ -275,7 +275,7 @@ namespace Components
const auto* cmd = params->get(0); const auto* cmd = params->get(0);
if (params->size() < 2) if (params->size() < 2)
{ {
Logger::Print("Usage: %s <client number> : prevent the player from using the chat\n", cmd); Logger::Print("Usage: {} <client number> : prevent the player from using the chat\n", cmd);
return; return;
} }
@ -297,7 +297,7 @@ namespace Components
const auto* cmd = params->get(0); const auto* cmd = params->get(0);
if (params->size() < 2) if (params->size() < 2)
{ {
Logger::Print("Usage: %s <client number or guid>\n%s all = unmute everyone\n", cmd, cmd); Logger::Print("Usage: {} <client number or guid>\n{} all = unmute everyone\n", cmd, cmd);
return; return;
} }

View File

@ -10,14 +10,14 @@ namespace Components
if (!Dvar::Var("sv_cheats").get<bool>()) if (!Dvar::Var("sv_cheats").get<bool>())
{ {
Logger::Print("CheatsOk: cheats are disabled!\n"); Logger::DebugInfo("Cheats are disabled!");
Game::SV_GameSendServerCommand(entNum, Game::SV_CMD_CAN_IGNORE, Utils::String::VA("%c \"GAME_CHEATSNOTENABLED\"", 0x65)); Game::SV_GameSendServerCommand(entNum, Game::SV_CMD_CAN_IGNORE, Utils::String::VA("%c \"GAME_CHEATSNOTENABLED\"", 0x65));
return false; return false;
} }
if (ent->health < 1) if (ent->health < 1)
{ {
Logger::Print("CheatsOk: entity %i must be alive to use this command!\n", entNum); Logger::DebugInfo("Entity {} must be alive to use this command!", entNum);
Game::SV_GameSendServerCommand(entNum, Game::SV_CMD_CAN_IGNORE, Utils::String::VA("%c \"GAME_MUSTBEALIVECOMMAND\"", 0x65)); Game::SV_GameSendServerCommand(entNum, Game::SV_CMD_CAN_IGNORE, Utils::String::VA("%c \"GAME_MUSTBEALIVECOMMAND\"", 0x65));
return false; return false;
} }
@ -38,7 +38,7 @@ namespace Components
if (ent->client == nullptr) if (ent->client == nullptr)
{ {
Logger::Print("ClientCommand: client %d is not fully in game yet\n", clientNum); Logger::DebugInfo("ClientCommand: client {} is not fully in game yet", clientNum);
return; return;
} }
@ -64,7 +64,7 @@ namespace Components
ent->client->flags ^= Game::PLAYER_FLAG_NOCLIP; ent->client->flags ^= Game::PLAYER_FLAG_NOCLIP;
const auto entNum = ent->s.number; const auto entNum = ent->s.number;
Logger::Print("Noclip toggled for entity %i\n", entNum); Logger::DebugInfo("Noclip toggled for entity {}", entNum);
Game::SV_GameSendServerCommand(entNum, Game::SV_CMD_CAN_IGNORE, Utils::String::VA("%c \"%s\"", 0x65, Game::SV_GameSendServerCommand(entNum, Game::SV_CMD_CAN_IGNORE, Utils::String::VA("%c \"%s\"", 0x65,
(ent->client->flags & Game::PLAYER_FLAG_NOCLIP) ? "GAME_NOCLIPON" : "GAME_NOCLIPOFF")); (ent->client->flags & Game::PLAYER_FLAG_NOCLIP) ? "GAME_NOCLIPON" : "GAME_NOCLIPOFF"));
@ -78,7 +78,7 @@ namespace Components
ent->client->flags ^= Game::PLAYER_FLAG_UFO; ent->client->flags ^= Game::PLAYER_FLAG_UFO;
const auto entNum = ent->s.number; const auto entNum = ent->s.number;
Logger::Print("UFO toggled for entity %i\n", entNum); Logger::DebugInfo("UFO toggled for entity {}", entNum);
Game::SV_GameSendServerCommand(entNum, Game::SV_CMD_CAN_IGNORE, Utils::String::VA("%c \"%s\"", 0x65, Game::SV_GameSendServerCommand(entNum, Game::SV_CMD_CAN_IGNORE, Utils::String::VA("%c \"%s\"", 0x65,
(ent->client->flags & Game::PLAYER_FLAG_UFO) ? "GAME_UFOON" : "GAME_UFOOFF")); (ent->client->flags & Game::PLAYER_FLAG_UFO) ? "GAME_UFOON" : "GAME_UFOOFF"));
@ -92,7 +92,7 @@ namespace Components
ent->flags ^= Game::FL_GODMODE; ent->flags ^= Game::FL_GODMODE;
const auto entNum = ent->s.number; const auto entNum = ent->s.number;
Logger::Print("God toggled for entity %i\n", entNum); Logger::DebugInfo("God toggled for entity {}", entNum);
Game::SV_GameSendServerCommand(entNum, Game::SV_CMD_CAN_IGNORE, Utils::String::VA("%c \"%s\"", 0x65, Game::SV_GameSendServerCommand(entNum, Game::SV_CMD_CAN_IGNORE, Utils::String::VA("%c \"%s\"", 0x65,
(ent->flags & Game::FL_GODMODE) ? "GAME_GODMODE_ON" : "GAME_GODMODE_OFF")); (ent->flags & Game::FL_GODMODE) ? "GAME_GODMODE_ON" : "GAME_GODMODE_OFF"));
@ -106,7 +106,7 @@ namespace Components
ent->flags ^= Game::FL_DEMI_GODMODE; ent->flags ^= Game::FL_DEMI_GODMODE;
const auto entNum = ent->s.number; const auto entNum = ent->s.number;
Logger::Print("Demigod toggled for entity %i\n", entNum); Logger::DebugInfo("Demigod toggled for entity {}", entNum);
Game::SV_GameSendServerCommand(entNum, Game::SV_CMD_CAN_IGNORE, Utils::String::VA("%c \"%s\"", 0x65, Game::SV_GameSendServerCommand(entNum, Game::SV_CMD_CAN_IGNORE, Utils::String::VA("%c \"%s\"", 0x65,
(ent->flags & Game::FL_DEMI_GODMODE) ? "GAME_DEMI_GODMODE_ON" : "GAME_DEMI_GODMODE_OFF")); (ent->flags & Game::FL_DEMI_GODMODE) ? "GAME_DEMI_GODMODE_ON" : "GAME_DEMI_GODMODE_OFF"));
@ -120,7 +120,7 @@ namespace Components
ent->flags ^= Game::FL_NOTARGET; ent->flags ^= Game::FL_NOTARGET;
const auto entNum = ent->s.number; const auto entNum = ent->s.number;
Logger::Print("Notarget toggled for entity %i\n", entNum); Logger::DebugInfo("Notarget toggled for entity {}", entNum);
Game::SV_GameSendServerCommand(entNum, Game::SV_CMD_CAN_IGNORE, Utils::String::VA("%c \"%s\"", 0x65, Game::SV_GameSendServerCommand(entNum, Game::SV_CMD_CAN_IGNORE, Utils::String::VA("%c \"%s\"", 0x65,
(ent->flags & Game::FL_NOTARGET) ? "GAME_NOTARGETON" : "GAME_NOTARGETOFF")); (ent->flags & Game::FL_NOTARGET) ? "GAME_NOTARGETON" : "GAME_NOTARGETOFF"));
@ -157,6 +157,8 @@ namespace Components
angles[0] = std::strtof(params->get(5), nullptr); // Pitch angles[0] = std::strtof(params->get(5), nullptr); // Pitch
} }
Logger::DebugInfo("Teleported entity {} to {:f} {:f} {:f}\nviewpos {:f} {:f}", ent->s.number,
origin[0], origin[1], origin[2], angles[0], angles[2]);
Game::TeleportPlayer(ent, origin, angles); Game::TeleportPlayer(ent, origin, angles);
}); });
} }
@ -180,7 +182,7 @@ namespace Components
ClientCommand::Add("entitycount", []([[maybe_unused]] Game::gentity_s* ent, [[maybe_unused]] Command::ServerParams* params) ClientCommand::Add("entitycount", []([[maybe_unused]] Game::gentity_s* ent, [[maybe_unused]] Command::ServerParams* params)
{ {
Logger::Print("Entity count = %i\n", Game::level->num_entities); Logger::Print("Entity count = {}\n", Game::level->num_entities);
}); });
// Also known as: "vis" // Also known as: "vis"
@ -243,7 +245,9 @@ namespace Components
ClientCommand::Add("g_testCmd", []([[maybe_unused]] Game::gentity_s* ent, [[maybe_unused]] Command::ServerParams* params) ClientCommand::Add("g_testCmd", []([[maybe_unused]] Game::gentity_s* ent, [[maybe_unused]] Command::ServerParams* params)
{ {
assert(ent != nullptr); assert(ent != nullptr);
ent->client->ps.stunTime = 1000 + Game::level->time; // 1000 is the default test stun time ent->client->ps.stunTime = 1000 + Game::level->time; // 1000 is the default test stun time
Logger::DebugInfo("playerState_s.stunTime is {}", ent->client->ps.stunTime);
}); });
ClientCommand::Add("kill", []([[maybe_unused]] Game::gentity_s* ent, [[maybe_unused]] Command::ServerParams* params) ClientCommand::Add("kill", []([[maybe_unused]] Game::gentity_s* ent, [[maybe_unused]] Command::ServerParams* params)
@ -277,6 +281,7 @@ namespace Components
Game::level->initializing = 1; Game::level->initializing = 1;
const auto* weaponName = params->get(1); const auto* weaponName = params->get(1);
Logger::DebugInfo("Giving weapon {} to entity {}", weaponName, ent->s.number);
const auto weaponIndex = Game::G_GetWeaponIndexForName(weaponName); const auto weaponIndex = Game::G_GetWeaponIndexForName(weaponName);
if (weaponIndex == 0) if (weaponIndex == 0)
@ -287,8 +292,8 @@ namespace Components
if (Game::BG_GetWeaponDef(weaponIndex)->inventoryType == Game::weapInventoryType_t::WEAPINVENTORY_ALTMODE) if (Game::BG_GetWeaponDef(weaponIndex)->inventoryType == Game::weapInventoryType_t::WEAPINVENTORY_ALTMODE)
{ {
Game::Com_PrintError(Game::CON_CHANNEL_ERROR, Logger::PrintError(Game::CON_CHANNEL_ERROR,
"You can't directly spawn the altfire weapon '%s'. Spawn a weapon that has this altmode instead.\n", weaponName); "You can't directly spawn the altfire weapon '{}'. Spawn a weapon that has this altmode instead.\n", weaponName);
Game::level->initializing = 0; Game::level->initializing = 0;
return; return;
} }
@ -310,9 +315,11 @@ namespace Components
case Game::OFFHAND_CLASS_FRAG_GRENADE: case Game::OFFHAND_CLASS_FRAG_GRENADE:
case Game::OFFHAND_CLASS_THROWINGKNIFE: case Game::OFFHAND_CLASS_THROWINGKNIFE:
case Game::OFFHAND_CLASS_OTHER: case Game::OFFHAND_CLASS_OTHER:
Logger::DebugInfo("Setting offhandPrimary");
client->ps.weapCommon.offhandPrimary = offHandClass; client->ps.weapCommon.offhandPrimary = offHandClass;
break; break;
default: default:
Logger::DebugInfo("Setting offhandSecondary");
client->ps.weapCommon.offhandSecondary = offHandClass; client->ps.weapCommon.offhandSecondary = offHandClass;
break; break;
} }
@ -324,6 +331,7 @@ namespace Components
if (weapEnt->r.isInUse) if (weapEnt->r.isInUse)
{ {
Logger::DebugInfo("Freeing up entity {}", weapEnt->s.number);
Game::G_FreeEntity(weapEnt); Game::G_FreeEntity(weapEnt);
} }

View File

@ -13,8 +13,8 @@ namespace Components
int Console::Height = 25; int Console::Height = 25;
int Console::Width = 80; int Console::Width = 80;
char Console::LineBuffer[1024] = { 0 }; char Console::LineBuffer[1024] = {0};
char Console::LineBuffer2[1024] = { 0 }; char Console::LineBuffer2[1024] = {0};
int Console::LineBufferIndex = 0; int Console::LineBufferIndex = 0;
bool Console::HasConsole = false; bool Console::HasConsole = false;
@ -24,7 +24,7 @@ namespace Components
Game::SafeArea Console::OriginalSafeArea; Game::SafeArea Console::OriginalSafeArea;
char** Console::GetAutoCompleteFileList(const char *path, const char *extension, Game::FsListBehavior_e behavior, int *numfiles, int allocTrackType) char** Console::GetAutoCompleteFileList(const char* path, const char* extension, Game::FsListBehavior_e behavior, int* numfiles, int allocTrackType)
{ {
if (path == reinterpret_cast<char*>(0xBAADF00D) || path == reinterpret_cast<char*>(0xCDCDCDCD) || ::Utils::Memory::IsBadReadPtr(path)) return nullptr; if (path == reinterpret_cast<char*>(0xBAADF00D) || path == reinterpret_cast<char*>(0xCDCDCDCD) || ::Utils::Memory::IsBadReadPtr(path)) return nullptr;
return Game::FS_GetFileList(path, extension, behavior, numfiles, allocTrackType); return Game::FS_GetFileList(path, extension, behavior, numfiles, allocTrackType);
@ -44,8 +44,8 @@ namespace Components
void Console::RefreshStatus() void Console::RefreshStatus()
{ {
std::string mapname = Dvar::Var("mapname").get<const char*>(); const auto mapname = Dvar::Var("mapname").get<std::string>();
std::string hostname = TextRenderer::StripColors(Dvar::Var("sv_hostname").get<const char*>()); const auto hostname = TextRenderer::StripColors(Dvar::Var("sv_hostname").get<std::string>());
if (Console::HasConsole) if (Console::HasConsole)
{ {
@ -72,7 +72,7 @@ namespace Components
} }
wclear(Console::InfoWindow); wclear(Console::InfoWindow);
wprintw(Console::InfoWindow, "%s : %d/%d players : map %s", hostname.data(), clientCount, maxclientCount, (mapname.size() ? mapname.data() : "none")); wprintw(Console::InfoWindow, "%s : %d/%d players : map %s", hostname.data(), clientCount, maxclientCount, (!mapname.empty()) ? mapname.data() : "none");
wnoutrefresh(Console::InfoWindow); wnoutrefresh(Console::InfoWindow);
} }
else if (IsWindow(Console::GetWindow()) != FALSE) else if (IsWindow(Console::GetWindow()) != FALSE)
@ -318,17 +318,16 @@ namespace Components
Console::RefreshOutput(); Console::RefreshOutput();
} }
void Console::Error(const char* format, ...) void Console::Error(const char* fmt, ...)
{ {
static char buffer[32768]; char buf[4096] = {0};
va_list va; va_list va;
va_start(va, format); va_start(va, fmt);
_vsnprintf_s(buffer, sizeof(buffer), format, va); _vsnprintf_s(buf, _TRUNCATE, fmt, va);
va_end(va); va_end(va);
Game::Com_Printf(0, "ERROR:\n"); Logger::PrintError(Game::CON_CHANNEL_ERROR, "{}", buf);
Game::Com_Printf(0, buffer);
Console::RefreshOutput(); Console::RefreshOutput();
@ -426,13 +425,13 @@ namespace Components
fflush(stdout); fflush(stdout);
} }
void Console::StdOutError(const char* format, ...) void Console::StdOutError(const char* fmt, ...)
{ {
char buffer[0x1000] = { 0 }; char buffer[4096] = {0};
va_list ap; va_list ap;
va_start(ap, format); va_start(ap, fmt);
_vsnprintf_s(buffer, sizeof(buffer), format, ap); _vsnprintf_s(buffer, _TRUNCATE, fmt, ap);
va_end(ap); va_end(ap);
perror(buffer); perror(buffer);
@ -520,7 +519,7 @@ namespace Components
{ "con_outputWindowColor", { 0.25f, 0.25f, 0.25f, 0.85f } }, { "con_outputWindowColor", { 0.25f, 0.25f, 0.25f, 0.85f } },
}; };
for (int i = 0; i < ARRAYSIZE(patchedColors); ++i) for (std::size_t i = 0; i < ARRAYSIZE(patchedColors); ++i)
{ {
if (std::strcmp(dvarName, patchedColors[i].name) == 0) if (std::strcmp(dvarName, patchedColors[i].name) == 0)
{ {

View File

@ -50,12 +50,12 @@ namespace Components
static const char* Input(); static const char* Input();
static void Print(const char* message); static void Print(const char* message);
static void Error(const char* format, ...); static void Error(const char* fmt, ...);
static void Create(); static void Create();
static void Destroy(); static void Destroy();
static void StdOutPrint(const char* message); static void StdOutPrint(const char* message);
static void StdOutError(const char* format, ...); static void StdOutError(const char* fmt, ...);
static void ConsoleRunner(); static void ConsoleRunner();

View File

@ -573,7 +573,7 @@ namespace Components
// TODO: Fix the actual error! // TODO: Fix the actual error!
if (IsBadReadPtr(pConstantData, Vector4fCount * 16)) if (IsBadReadPtr(pConstantData, Vector4fCount * 16))
{ {
//Logger::Print("Invalid shader constant array!\n"); Logger::DebugInfo("Invalid shader constant array!");
return D3DERR_INVALIDCALL; return D3DERR_INVALIDCALL;
} }

View File

@ -135,7 +135,7 @@ namespace Components
Network::Address master(Utils::String::VA("%s:%u", masterServerName, masterPort)); Network::Address master(Utils::String::VA("%s:%u", masterServerName, masterPort));
Logger::Print(Game::conChannel_t::CON_CHANNEL_SERVER, "Sending heartbeat to master: %s:%u\n", masterServerName, masterPort); Logger::Print(Game::CON_CHANNEL_SERVER, "Sending heartbeat to master: {}:{}\n", masterServerName, masterPort);
Network::SendCommand(master, "heartbeat", "IW4"); Network::SendCommand(master, "heartbeat", "IW4");
} }
@ -160,12 +160,12 @@ namespace Components
if (!name.empty()) if (!name.empty())
{ {
Game::SV_GameSendServerCommand(-1, Game::SV_CMD_CAN_IGNORE, Utils::String::VA("%c \"%s: %s\"", 104, name.data(), message.data())); Game::SV_GameSendServerCommand(-1, Game::SV_CMD_CAN_IGNORE, Utils::String::VA("%c \"%s: %s\"", 104, name.data(), message.data()));
Game::Com_Printf(15, "%s: %s\n", name.data(), message.data()); Logger::Print(Game::CON_CHANNEL_SERVER, "{}: {}\n", name, message);
} }
else else
{ {
Game::SV_GameSendServerCommand(-1, Game::SV_CMD_CAN_IGNORE, Utils::String::VA("%c \"Console: %s\"", 104, message.data())); Game::SV_GameSendServerCommand(-1, Game::SV_CMD_CAN_IGNORE, Utils::String::VA("%c \"Console: %s\"", 104, message.data()));
Game::Com_Printf(15, "Console: %s\n", message.data()); Logger::Print(Game::CON_CHANNEL_SERVER, "Console: {}\n", message);
} }
}); });
@ -181,12 +181,12 @@ namespace Components
if (!name.empty()) if (!name.empty())
{ {
Game::SV_GameSendServerCommand(client, Game::SV_CMD_CAN_IGNORE, Utils::String::VA("%c \"%s: %s\"", 104, name.data(), message.data())); Game::SV_GameSendServerCommand(client, Game::SV_CMD_CAN_IGNORE, Utils::String::VA("%c \"%s: %s\"", 104, name.data(), message.data()));
Game::Com_Printf(15, "%s -> %i: %s\n", name.data(), client, message.data()); Logger::Print(Game::CON_CHANNEL_SERVER, "{} -> {}: {}\n", name, client, message);
} }
else else
{ {
Game::SV_GameSendServerCommand(client, Game::SV_CMD_CAN_IGNORE, Utils::String::VA("%c \"Console: %s\"", 104, message.data())); Game::SV_GameSendServerCommand(client, Game::SV_CMD_CAN_IGNORE, Utils::String::VA("%c \"Console: %s\"", 104, message.data()));
Game::Com_Printf(15, "Console -> %i: %s\n", client, message.data()); Logger::Print(Game::CON_CHANNEL_SERVER, "Console -> {}: {}\n", client, message);
} }
}); });
@ -197,7 +197,7 @@ namespace Components
auto message = params->join(1); auto message = params->join(1);
Game::SV_GameSendServerCommand(-1, Game::SV_CMD_CAN_IGNORE, Utils::String::VA("%c \"%s\"", 104, message.data())); Game::SV_GameSendServerCommand(-1, Game::SV_CMD_CAN_IGNORE, Utils::String::VA("%c \"%s\"", 104, message.data()));
Game::Com_Printf(15, "Raw: %s\n", message.data()); Logger::Print(Game::CON_CHANNEL_SERVER, "Raw: {}\n", message);
}); });
// Tellraw command // Tellraw command
@ -208,7 +208,7 @@ namespace Components
const auto client = atoi(params->get(1)); const auto client = atoi(params->get(1));
std::string message = params->join(2); std::string message = params->join(2);
Game::SV_GameSendServerCommand(client, Game::SV_CMD_CAN_IGNORE, Utils::String::VA("%c \"%s\"", 104, message.data())); Game::SV_GameSendServerCommand(client, Game::SV_CMD_CAN_IGNORE, Utils::String::VA("%c \"%s\"", 104, message.data()));
Game::Com_Printf(15, "Raw -> %i: %s\n", client, message.data()); Logger::Print(Game::CON_CHANNEL_SERVER, "Raw -> {}: {}\n", client, message);
}); });
} }

View File

@ -37,7 +37,7 @@ namespace Components
unsigned int maxPort = Dvar::Var("net_discoveryPortRangeMax").get<unsigned int>(); unsigned int maxPort = Dvar::Var("net_discoveryPortRangeMax").get<unsigned int>();
Network::BroadcastRange(minPort, maxPort, Utils::String::VA("discovery %s", Discovery::Challenge.data())); Network::BroadcastRange(minPort, maxPort, Utils::String::VA("discovery %s", Discovery::Challenge.data()));
Logger::Print("Discovery sent within %dms, awaiting responses...\n", Game::Sys_Milliseconds() - start); Logger::Print("Discovery sent within {}ms, awaiting responses...\n", Game::Sys_Milliseconds() - start);
Discovery::IsPerforming = false; Discovery::IsPerforming = false;
} }
@ -52,11 +52,11 @@ namespace Components
if (!address.isLocal()) if (!address.isLocal())
{ {
Logger::Print("Received discovery request from non-local address: %s\n", address.getCString()); Logger::Print("Received discovery request from non-local address: {}\n", address.getCString());
return; return;
} }
Logger::Print("Received discovery request from %s\n", address.getCString()); Logger::Print("Received discovery request from {}\n", address.getCString());
Network::SendCommand(address, "discoveryResponse", data); Network::SendCommand(address, "discoveryResponse", data);
}); });
@ -66,17 +66,17 @@ namespace Components
if (!address.isLocal()) if (!address.isLocal())
{ {
Logger::Print("Received discovery response from non-local address: %s\n", address.getCString()); Logger::Print("Received discovery response from non-local address: {}\n", address.getCString());
return; return;
} }
if (Utils::ParseChallenge(data) != Discovery::Challenge) if (Utils::ParseChallenge(data) != Discovery::Challenge)
{ {
Logger::Print("Received discovery with invalid challenge from: %s\n", address.getCString()); Logger::Print("Received discovery with invalid challenge from: {}\n", address.getCString());
return; return;
} }
Logger::Print("Received discovery response from: %s\n", address.getCString()); Logger::Print("Received discovery response from: {}\n", address.getCString());
if (ServerList::IsOfflineList()) if (ServerList::IsOfflineList())
{ {

View File

@ -66,7 +66,7 @@ namespace Components
if (!error.empty() || !listData.is_array()) if (!error.empty() || !listData.is_array())
{ {
Logger::Print("Error: %s\n", error.data()); Logger::Print("Error: {}\n", error);
return false; return false;
} }
@ -201,7 +201,7 @@ namespace Components
+ (download->isPrivate ? ("?password=" + download->hashedPassword) : ""); + (download->isPrivate ? ("?password=" + download->hashedPassword) : "");
} }
Logger::Print("Downloading from url %s\n", url.data()); Logger::Print("Downloading from url {}\n", url);
Download::FileDownload fDownload; Download::FileDownload fDownload;
fDownload.file = file; fDownload.file = file;

View File

@ -224,7 +224,7 @@ namespace Components
std::string saneName = TextRenderer::StripAllTextIcons(TextRenderer::StripColors(Utils::String::Trim(name))); std::string saneName = TextRenderer::StripAllTextIcons(TextRenderer::StripColors(Utils::String::Trim(name)));
if (saneName.size() < 3 || (saneName[0] == '[' && saneName[1] == '{')) if (saneName.size() < 3 || (saneName[0] == '[' && saneName[1] == '{'))
{ {
Logger::Print("Username '%s' is invalid. It must at least be 3 characters long and not appear empty!\n", name.data()); Logger::Print("Username '{}' is invalid. It must at least be 3 characters long and not appear empty!\n", name);
Dvar::Var("name").set(lastValidName); Dvar::Var("name").set(lastValidName);
} }
else else

View File

@ -203,6 +203,7 @@ namespace Components
//Utils::Hook(0x4B241F, Exception::ErrorLongJmp, HOOK_CALL).install()->quick(); //Utils::Hook(0x4B241F, Exception::ErrorLongJmp, HOOK_CALL).install()->quick();
Utils::Hook(0x6B8898, Exception::LongJmp, HOOK_JUMP).install()->quick(); Utils::Hook(0x6B8898, Exception::LongJmp, HOOK_JUMP).install()->quick();
#ifdef _DEBUG
Command::Add("mapTest", [](Command::Params* params) Command::Add("mapTest", [](Command::Params* params)
{ {
Game::UI_UpdateArenas(); Game::UI_UpdateArenas();
@ -210,22 +211,16 @@ namespace Components
std::string command; std::string command;
for (auto i = 0; i < (params->size() >= 2 ? atoi(params->get(1)) : *Game::arenaCount); ++i) for (auto i = 0; i < (params->size() >= 2 ? atoi(params->get(1)) : *Game::arenaCount); ++i)
{ {
const auto* mapname = ArenaLength::NewArenas[i % *Game::arenaCount].mapName; const auto* mapName = ArenaLength::NewArenas[i % *Game::arenaCount].mapName;
if (!(i % 2)) command.append("wait 250;disconnect;wait 750;"); // Test a disconnect if (!(i % 2)) command.append("wait 250;disconnect;wait 750;"); // Test a disconnect
else command.append("wait 500;"); // Test direct map switch else command.append("wait 500;"); // Test direct map switch
command.append(Utils::String::VA("map %s;", mapname)); command.append(Utils::String::VA("map %s;", mapName));
} }
Command::Execute(command, false); Command::Execute(command, false);
}); });
#endif
Command::Add("debug_exceptionhandler", [](Command::Params*)
{
Logger::Print("Rerunning SetUnhandledExceptionHandler...\n");
auto oldHandler = Exception::Hook();
Logger::Print("Old exception handler was 0x%010X.\n", oldHandler);
});
} }
Exception::~Exception() Exception::~Exception()

View File

@ -327,7 +327,7 @@ namespace Components
if (*version != XFILE_VERSION) if (*version != XFILE_VERSION)
{ {
Logger::Error("Zone version %d is not supported!", Zones::Version()); Logger::Error(Game::ERR_FATAL, "Zone version {} is not supported!", Zones::Version());
} }
} }
@ -343,11 +343,11 @@ namespace Components
if (header[1] < XFILE_VERSION_IW4X) if (header[1] < XFILE_VERSION_IW4X)
{ {
Logger::Error("The fastfile you are trying to load is outdated (%d, expected %d)", header[1], XFILE_VERSION_IW4X); Logger::Error(Game::ERR_FATAL, "The fastfile you are trying to load is outdated ({}, expected {})", header[1], XFILE_VERSION_IW4X);
} }
else if (header[1] > XFILE_VERSION_IW4X) else if (header[1] > XFILE_VERSION_IW4X)
{ {
Logger::Error("You are loading a fastfile that is too new (%d, expected %d), update your game or rebuild the fastfile", header[1], XFILE_VERSION_IW4X); Logger::Error(Game::ERR_FATAL, "You are loading a fastfile that is too new ({}, expected {}), update your game or rebuild the fastfile", header[1], XFILE_VERSION_IW4X);
} }
*reinterpret_cast<unsigned __int64*>(header) = XFILE_MAGIC_UNSIGNED; *reinterpret_cast<unsigned __int64*>(header) = XFILE_MAGIC_UNSIGNED;

View File

@ -31,7 +31,7 @@ namespace Components
if (retval == SOCKET_ERROR) if (retval == SOCKET_ERROR)
{ {
Logger::Print("Warning: select() syscall failed: %s\n", Game::NET_ErrorString()); Logger::Warning(Game::CON_CHANNEL_SYSTEM, "Select() syscall failed: {}\n", Game::NET_ErrorString());
} }
else if (retval > 0) else if (retval > 0)
{ {

View File

@ -591,7 +591,7 @@ namespace Components
{ {
if (params->size() < 2u) if (params->size() < 2u)
{ {
Logger::Print("Usage: %s <Steam ID in hexadecimal format>\n", params->get(0)); Logger::Print("Usage: {} <Steam ID in hexadecimal format>\n", params->get(0));
return; return;
} }

View File

@ -1390,17 +1390,15 @@ namespace Components
GPad_UpdateSticksDown(gamePadIndex); GPad_UpdateSticksDown(gamePadIndex);
#ifdef DEBUG
if (gpad_debug.get<bool>()) if (gpad_debug.get<bool>())
{ {
Logger::Print("Left: X: %f Y: %f\n", lVec[0], lVec[1]); Logger::Debug("Left: X: {:f} Y: {:f}", lVec[0], lVec[1]);
Logger::Print("Right: X: %f Y: %f\n", rVec[0], rVec[1]); Logger::Debug("Right: X: {:f} Y: {:f}", rVec[0], rVec[1]);
Logger::Print("Down: %i:%i %i:%i %i:%i %i:%i\n", gamePad.stickDown[0][Game::GPAD_STICK_POS], gamePad.stickDown[0][Game::GPAD_STICK_NEG], Logger::Debug("Down: {}:{} {}:{} {}:{} {}:{}", gamePad.stickDown[0][Game::GPAD_STICK_POS], gamePad.stickDown[0][Game::GPAD_STICK_NEG],
gamePad.stickDown[1][Game::GPAD_STICK_POS], gamePad.stickDown[1][Game::GPAD_STICK_NEG], gamePad.stickDown[1][Game::GPAD_STICK_POS], gamePad.stickDown[1][Game::GPAD_STICK_NEG],
gamePad.stickDown[2][Game::GPAD_STICK_POS], gamePad.stickDown[2][Game::GPAD_STICK_NEG], gamePad.stickDown[2][Game::GPAD_STICK_POS], gamePad.stickDown[2][Game::GPAD_STICK_NEG],
gamePad.stickDown[3][Game::GPAD_STICK_POS], gamePad.stickDown[3][Game::GPAD_STICK_NEG]); gamePad.stickDown[3][Game::GPAD_STICK_POS], gamePad.stickDown[3][Game::GPAD_STICK_NEG]);
} }
#endif
} }
void Gamepad::GPad_UpdateDigitals(const int gamePadIndex, const XINPUT_GAMEPAD& state) void Gamepad::GPad_UpdateDigitals(const int gamePadIndex, const XINPUT_GAMEPAD& state)
@ -1419,12 +1417,10 @@ namespace Components
if (std::fabs(gamePad.sticks[2]) > leftDeflect || std::fabs(gamePad.sticks[3]) > rightDeflect) if (std::fabs(gamePad.sticks[2]) > leftDeflect || std::fabs(gamePad.sticks[3]) > rightDeflect)
gamePad.digitals &= ~static_cast<short>(XINPUT_GAMEPAD_RIGHT_THUMB); gamePad.digitals &= ~static_cast<short>(XINPUT_GAMEPAD_RIGHT_THUMB);
#ifdef DEBUG
if (gpad_debug.get<bool>()) if (gpad_debug.get<bool>())
{ {
Logger::Print("Buttons: %x\n", gamePad.digitals); Logger::Debug("Buttons: {:#x}", gamePad.digitals);
} }
#endif
} }
void Gamepad::GPad_UpdateAnalogs(const int gamePadIndex, const XINPUT_GAMEPAD& state) void Gamepad::GPad_UpdateAnalogs(const int gamePadIndex, const XINPUT_GAMEPAD& state)
@ -1446,12 +1442,10 @@ namespace Components
if (gamePad.analogs[1] < buttonDeadZone) if (gamePad.analogs[1] < buttonDeadZone)
gamePad.analogs[1] = 0.0f; gamePad.analogs[1] = 0.0f;
#ifdef DEBUG
if (gpad_debug.get<bool>()) if (gpad_debug.get<bool>())
{ {
Logger::Print("Triggers: %f %f\n", gamePad.analogs[0], gamePad.analogs[1]); Logger::Debug("Triggers: {:f} {:f}", gamePad.analogs[0], gamePad.analogs[1]);
} }
#endif
} }
void Gamepad::GPad_UpdateAll() void Gamepad::GPad_UpdateAll()
@ -1658,21 +1652,21 @@ namespace Components
const Game::GamepadPhysicalAxis physicalAxis = StringToPhysicalAxis(physicalAxisText); const Game::GamepadPhysicalAxis physicalAxis = StringToPhysicalAxis(physicalAxisText);
if (physicalAxis == Game::GPAD_PHYSAXIS_NONE) if (physicalAxis == Game::GPAD_PHYSAXIS_NONE)
{ {
Logger::Print("\"%s\" isn't a valid physical axis\n", physicalAxisText); Logger::Print("\"{}\" isn't a valid physical axis\n", physicalAxisText);
return; return;
} }
const Game::GamepadVirtualAxis virtualAxis = StringToVirtualAxis(virtualAxisText); const Game::GamepadVirtualAxis virtualAxis = StringToVirtualAxis(virtualAxisText);
if (virtualAxis == Game::GPAD_VIRTAXIS_NONE) if (virtualAxis == Game::GPAD_VIRTAXIS_NONE)
{ {
Logger::Print("\"%s\" isn't a valid virtual axis\n", virtualAxisText); Logger::Print("\"{}\" isn't a valid virtual axis\n", virtualAxisText);
return; return;
} }
const Game::GamepadMapping mapping = StringToGamePadMapping(mappingText); const Game::GamepadMapping mapping = StringToGamePadMapping(mappingText);
if (mapping == Game::GPAD_MAP_NONE) if (mapping == Game::GPAD_MAP_NONE)
{ {
Logger::Print("\"%s\" isn't a valid input type\n", mappingText); Logger::Print("\"{}\" isn't a valid input type\n", mappingText);
return; return;
} }

View File

@ -12,79 +12,88 @@ namespace Components
return (IsWindow(Console::GetWindow()) != FALSE || (Dedicated::IsEnabled() && !Flags::HasFlag("console"))); return (IsWindow(Console::GetWindow()) != FALSE || (Dedicated::IsEnabled() && !Flags::HasFlag("console")));
} }
void Logger::PrintStub(int channel, const char* message, ...) void Logger::PrintStub(const int channel, const char* message, ...)
{ {
return Logger::MessagePrint(channel, Logger::Format(&message)); char buf[4096] = {0};
va_list va;
va_start(va, message);
_vsnprintf_s(buf, _TRUNCATE, message, va);
va_end(va);
Logger::MessagePrint(channel, {buf});
} }
void Logger::Print(const char* message, ...) void Logger::MessagePrint(const int channel, const std::string& msg)
{
return Logger::MessagePrint(0, Logger::Format(&message));
}
void Logger::Print(int channel, const char* message, ...)
{
return Logger::MessagePrint(channel, Logger::Format(&message));
}
void Logger::MessagePrint(int channel, const std::string& message)
{ {
if (Flags::HasFlag("stdout") || Loader::IsPerformingUnitTests()) if (Flags::HasFlag("stdout") || Loader::IsPerformingUnitTests())
{ {
printf("%s", message.data()); printf("%s", msg.data());
fflush(stdout); fflush(stdout);
return; return;
} }
if (!Logger::IsConsoleReady()) if (!Logger::IsConsoleReady())
{ {
OutputDebugStringA(message.data()); OutputDebugStringA(msg.data());
} }
if (!Game::Sys_IsMainThread()) if (!Game::Sys_IsMainThread())
{ {
Logger::EnqueueMessage(message); Logger::EnqueueMessage(msg);
} }
else else
{ {
Game::Com_PrintMessage(channel, message.data(), 0); Game::Com_PrintMessage(channel, msg.data(), 0);
} }
} }
void Logger::ErrorPrint(Game::errorParm_t error, const std::string& message) void Logger::DebugInternal(const bool verbose, const std::source_location& srcLoc, const std::string_view fmt, std::format_args&& args)
{ {
#ifdef DEBUG const auto msg = std::vformat(fmt, args);
const auto out = verbose
? std::format("Debug:\n {}\nFile: {}\nLine: {}\n", msg, srcLoc.file_name(), srcLoc.line())
: std::format("Debug:\n {}\n", msg);
Logger::MessagePrint(Game::CON_CHANNEL_DONT_FILTER, out);
}
void Logger::PrintInternal(int channel, std::string_view fmt, std::format_args&& args)
{
const auto msg = std::vformat(fmt, args);
Logger::MessagePrint(channel, msg);
}
void Logger::ErrorInternal(const Game::errorParm_t error, const std::string_view fmt, std::format_args&& args)
{
#ifdef _DEBUG
if (IsDebuggerPresent()) __debugbreak(); if (IsDebuggerPresent()) __debugbreak();
#endif #endif
return Game::Com_Error(error, "%s", message.data()); const auto msg = std::vformat(fmt, args);
Game::Com_Error(error, "%s", msg.data());
} }
void Logger::Error(Game::errorParm_t error, const char* message, ...) void Logger::PrintErrorInternal(int channel, std::string_view fmt, std::format_args&& args)
{ {
return Logger::ErrorPrint(error, Logger::Format(&message)); const auto msg = "^1Error: " + std::vformat(fmt, args);
++(*Game::com_errorPrintsCount);
Logger::MessagePrint(channel, msg);
if (*Game::cls_uiStarted != 0 && (*Game::com_fixedConsolePosition == 0))
{
Game::CL_ConsoleFixPosition();
}
} }
void Logger::Error(const char* message, ...) void Logger::WarningInternal(int channel, std::string_view fmt, std::format_args&& args)
{ {
return Logger::ErrorPrint(Game::ERR_FATAL, Logger::Format(&message)); const auto msg = "^3" + std::vformat(fmt, args);
}
void Logger::SoftError(const char* message, ...) Logger::MessagePrint(channel, msg);
{
return Logger::ErrorPrint(Game::ERR_SERVERDISCONNECT, Logger::Format(&message));
}
std::string Logger::Format(const char** message)
{
char buffer[4096] = {0};
va_list ap = reinterpret_cast<char*>(const_cast<char**>(&message[1]));
_vsnprintf_s(buffer, _TRUNCATE, *message, ap);
va_end(ap);
return {buffer};
} }
void Logger::Flush() void Logger::Flush()
@ -106,9 +115,9 @@ namespace Components
{ {
std::lock_guard<std::mutex> _(Logger::MessageMutex); std::lock_guard<std::mutex> _(Logger::MessageMutex);
for (unsigned int i = 0; i < Logger::MessageQueue.size(); ++i) for (std::size_t i = 0; i < Logger::MessageQueue.size(); ++i)
{ {
Game::Com_PrintMessage(0, Logger::MessageQueue[i].data(), 0); Game::Com_PrintMessage(Game::CON_CHANNEL_DONT_FILTER, Logger::MessageQueue[i].data(), 0);
if (!Logger::IsConsoleReady()) if (!Logger::IsConsoleReady())
{ {

View File

@ -7,14 +7,7 @@ namespace Components
public: public:
Logger(); Logger();
~Logger(); ~Logger();
static void MessagePrint(int channel, const std::string& message);
static void Print(int channel, const char* message, ...);
static void Print(const char* message, ...);
static void ErrorPrint(Game::errorParm_t error, const std::string& message);
static void Error(const char* message, ...);
static void Error(Game::errorParm_t error, const char* message, ...);
static void SoftError(const char* message, ...);
static bool IsConsoleReady(); static bool IsConsoleReady();
static void PrintStub(int channel, const char* message, ...); static void PrintStub(int channel, const char* message, ...);
@ -23,6 +16,110 @@ namespace Components
static void Flush(); static void Flush();
static void MessagePrint(int channel, const std::string& msg);
static void PrintInternal(int channel, std::string_view fmt, std::format_args&& args);
static void ErrorInternal(Game::errorParm_t error, std::string_view fmt, std::format_args&& args);
static void PrintErrorInternal(int channel, std::string_view fmt, std::format_args&& args);
static void WarningInternal(int channel, std::string_view fmt, std::format_args&& args);
static void DebugInternal(bool verbose, const std::source_location& srcLoc, std::string_view fmt, std::format_args&& args);
static inline void Print(std::string_view fmt)
{
PrintInternal(Game::CON_CHANNEL_DONT_FILTER, fmt, std::make_format_args(0));
}
static inline void Print(int channel, std::string_view fmt)
{
PrintInternal(channel, fmt, std::make_format_args(0));
}
template <typename... Args>
static inline void Print(std::string_view fmt, Args&&... args)
{
PrintInternal(Game::CON_CHANNEL_DONT_FILTER, fmt, std::make_format_args(args...));
}
template <typename... Args>
static inline void Print(int channel, std::string_view fmt, Args&&... args)
{
PrintInternal(channel, fmt, std::make_format_args(args...));
}
static inline void Error(Game::errorParm_t error, std::string_view fmt)
{
ErrorInternal(error, fmt, std::make_format_args(0));
}
template <typename... Args>
static inline void Error(Game::errorParm_t error, std::string_view fmt, Args&&... args)
{
ErrorInternal(error, fmt, std::make_format_args(args...));
}
static inline void Warning(int channel, std::string_view fmt)
{
WarningInternal(channel, fmt, std::make_format_args(0));
}
template <typename... Args>
static inline void Warning(int channel, std::string_view fmt, Args&&... args)
{
WarningInternal(channel, fmt, std::make_format_args(args...));
}
static inline void PrintError(int channel, std::string_view fmt)
{
PrintErrorInternal(channel, fmt, std::make_format_args(0));
}
template <typename... Args>
static inline void PrintError(int channel, std::string_view fmt, Args&&... args)
{
PrintErrorInternal(channel, fmt, std::make_format_args(args...));
}
#ifdef _DEBUG
static inline void DebugInfo([[maybe_unused]] std::string_view fmt)
{
DebugInternal(true, std::source_location::current(), fmt, std::make_format_args(0));
}
template <typename... Args>
static inline void DebugInfo([[maybe_unused]] std::string_view fmt, [[maybe_unused]] Args&&... args)
{
DebugInternal(true, std::source_location::current(), fmt, std::make_format_args(args...));
}
static inline void Debug([[maybe_unused]] std::string_view fmt)
{
DebugInternal(false, std::source_location::current(), fmt, std::make_format_args(0));
}
template <typename... Args>
static inline void Debug([[maybe_unused]] std::string_view fmt, [[maybe_unused]] Args&&... args)
{
DebugInternal(false, std::source_location::current(), fmt, std::make_format_args(args...));
}
#else
static inline void DebugInfo([[maybe_unused]] std::string_view fmt)
{
}
template <typename... Args>
static inline void DebugInfo([[maybe_unused]] std::string_view fmt, [[maybe_unused]] Args&&... args)
{
}
static inline void Debug([[maybe_unused]] std::string_view fmt)
{
}
template <typename... Args>
static inline void Debug([[maybe_unused]] std::string_view fmt, [[maybe_unused]] Args&&... args)
{
}
#endif
private: private:
static std::mutex MessageMutex; static std::mutex MessageMutex;
static std::vector<std::string> MessageQueue; static std::vector<std::string> MessageQueue;
@ -39,7 +136,5 @@ namespace Components
static void RedirectOSPath(const char* file, char* folder); static void RedirectOSPath(const char* file, char* folder);
static void NetworkLog(const char* data, bool gLog); static void NetworkLog(const char* data, bool gLog);
static std::string Format(const char** message);
}; };
} }

View File

@ -13,7 +13,7 @@ namespace Components
{ {
if (!this->world_) return; if (!this->world_) return;
Logger::Print("Exporting '%s'...\n", this->world_->baseName); Logger::Print("Exporting '{}'...\n", this->world_->baseName);
this->parseVertices(); this->parseVertices();
this->parseFaces(); this->parseFaces();
@ -471,7 +471,7 @@ namespace Components
MapDumper dumper(world); MapDumper dumper(world);
dumper.dump(); dumper.dump();
Logger::Print("Map '%s' exported!\n", world->baseName); Logger::Print("Map '{}' exported!\n", world->baseName);
} }
else else
{ {

View File

@ -612,8 +612,8 @@ namespace Components
{ {
if (error) if (error)
{ {
Components::Logger::SoftError("Missing DLC pack %s (%d) containing map %s (%s).\nPlease download it to play this map.", Logger::Error(Game::ERR_DISCONNECT, "Missing DLC pack {} ({}) containing map {} ({}).\nPlease download it to play this map.",
pack.name.data(), pack.index, Game::UI_LocalizeMapName(mapname), mapname); pack.name, pack.index, Game::UI_LocalizeMapName(mapname), mapname);
} }
return dlcIsTrue; return dlcIsTrue;
@ -621,7 +621,12 @@ namespace Components
} }
} }
if (error) Components::Logger::SoftError("Missing map file %s.\nYou may have a damaged installation or are attempting to load a non-existant map.", mapname); if (error)
{
Logger::Error(Game::ERR_DISCONNECT,
"Missing map file {}.\nYou may have a damaged installation or are attempting to load a non-existent map.", mapname);
}
return false; return false;
} }

View File

@ -43,9 +43,9 @@ namespace Components
void ModList::UIScript_LoadMods(UIScript::Token) void ModList::UIScript_LoadMods(UIScript::Token)
{ {
auto folder = Dvar::Var("fs_basepath").get<std::string>() + "\\mods"; auto folder = Dvar::Var("fs_basepath").get<std::string>() + "\\mods";
Game::Com_Printf(0, "Searching for mods in %s...\n", folder.data()); Logger::DebugInfo("Searching for mods in {}...\n", folder);
ModList::Mods = FileSystem::GetSysFileList(folder, "", true); ModList::Mods = FileSystem::GetSysFileList(folder, "", true);
Game::Com_Printf(0, "Found %i mods!\n", ModList::Mods.size()); Logger::DebugInfo("Found {} mods!\n", ModList::Mods.size());
} }
void ModList::UIScript_RunMod(UIScript::Token) void ModList::UIScript_RunMod(UIScript::Token)

View File

@ -56,18 +56,18 @@ namespace Components
} }
#endif #endif
Logger::Error("Loading model %s failed!", name.data()); Logger::Error(Game::ERR_FATAL, "Loading model {} failed!", name);
} }
Game::CModelHeader header; Game::CModelHeader header;
if (!model.read(&header, sizeof header)) if (!model.read(&header, sizeof header))
{ {
Logger::Error("Reading header for model %s failed!", name.data()); Logger::Error(Game::ERR_FATAL, "Reading header for model {} failed!", name);
} }
if (header.version != 1) if (header.version != 1)
{ {
Logger::Error("Model %s has an invalid version %d (should be 1)!", name.data(), header.version); Logger::Error(Game::ERR_FATAL, "Model {} has an invalid version {} (should be 1)!", name, header.version);
} }
// Allocate section buffers // Allocate section buffers
@ -82,7 +82,7 @@ namespace Components
model.seek(header.sectionHeader[i].offset, Game::FS_SEEK_SET); model.seek(header.sectionHeader[i].offset, Game::FS_SEEK_SET);
if (!model.read(header.sectionHeader[i].buffer, header.sectionHeader[i].size)) if (!model.read(header.sectionHeader[i].buffer, header.sectionHeader[i].size))
{ {
Logger::Error("Reading section %d for model %s failed!", i, name.data()); Logger::Error(Game::ERR_FATAL, "Reading section {} for model {} failed!", i, name);
} }
} }

View File

@ -266,7 +266,7 @@ namespace Components
{ {
if (client->reliableAcknowledge < 0) if (client->reliableAcknowledge < 0)
{ {
Logger::Print(Game::conChannel_t::CON_CHANNEL_NETWORK, "Negative reliableAcknowledge from %s - cl->reliableSequence is %i, reliableAcknowledge is %i\n", Logger::Print(Game::conChannel_t::CON_CHANNEL_NETWORK, "Negative reliableAcknowledge from {} - cl->reliableSequence is {}, reliableAcknowledge is {}\n",
client->name, client->reliableSequence, client->reliableAcknowledge); client->name, client->reliableSequence, client->reliableAcknowledge);
client->reliableAcknowledge = client->reliableSequence; client->reliableAcknowledge = client->reliableSequence;
Network::SendCommand(Game::NS_SERVER, client->netchan.remoteAddress, "error", "EXE_LOSTRELIABLECOMMANDS"); Network::SendCommand(Game::NS_SERVER, client->netchan.remoteAddress, "error", "EXE_LOSTRELIABLECOMMANDS");

View File

@ -13,7 +13,7 @@ namespace Components
if (News::Thread.joinable()) if (News::Thread.joinable())
{ {
Logger::Print("Awaiting thread termination...\n"); Logger::DebugInfo("Awaiting thread termination...");
News::Thread.join(); News::Thread.join();
if (!strcmp(Localization::Get("MPUI_MOTD_TEXT"), NEWS_MOTD_DEFAULT)) if (!strcmp(Localization::Get("MPUI_MOTD_TEXT"), NEWS_MOTD_DEFAULT))
@ -23,7 +23,7 @@ namespace Components
} }
else else
{ {
Logger::Print("Successfully fetched motd.\n"); Logger::DebugInfo("Successfully fetched motd");
} }
} }

View File

@ -41,7 +41,7 @@ namespace Components
Session::Send(this->address, "nodeListRequest"); Session::Send(this->address, "nodeListRequest");
Node::SendList(this->address); Node::SendList(this->address);
NODE_LOG("Sent request to %s\n", this->address.getCString()); Logger::DebugInfo("Sent request to {}\n", this->address.getCString());
} }
void Node::Entry::reset() void Node::Entry::reset()
@ -235,7 +235,7 @@ namespace Components
Proto::Node::List list; Proto::Node::List list;
if (!list.ParseFromString(data)) return; if (!list.ParseFromString(data)) return;
NODE_LOG("Received response from %s\n", address.getCString()); Logger::DebugInfo("Received response from {}\n", address.getCString());
std::lock_guard<std::recursive_mutex> _(Node::Mutex); std::lock_guard<std::recursive_mutex> _(Node::Mutex);
@ -253,12 +253,12 @@ namespace Components
{ {
if (!Dedicated::IsEnabled() && ServerList::IsOnlineList() && !ServerList::useMasterServer && list.protocol() == PROTOCOL) if (!Dedicated::IsEnabled() && ServerList::IsOnlineList() && !ServerList::useMasterServer && list.protocol() == PROTOCOL)
{ {
NODE_LOG("Inserting %s into the serverlist\n", address.getCString()); Logger::DebugInfo("Inserting {} into the serverlist\n", address.getCString());
ServerList::InsertRequest(address); ServerList::InsertRequest(address);
} }
else else
{ {
NODE_LOG("Dropping serverlist insertion for %s\n", address.getCString()); Logger::DebugInfo("Dropping serverlist insertion for {}\n", address.getCString());
} }
for (auto& node : Node::Nodes) for (auto& node : Node::Nodes)
@ -322,7 +322,7 @@ namespace Components
{ {
Scheduler::Once([&] Scheduler::Once([&]
{ {
NODE_LOG("Sending %d nodeListResponse length to %s\n", nodeListData.length(), address.getCString()); Logger::DebugInfo("Sending {} nodeListResponse length to {}\n", nodeListData.length(), address.getCString());
Session::Send(address, "nodeListResponse", nodeListData); Session::Send(address, "nodeListResponse", nodeListData);
}, Scheduler::Pipeline::MAIN, NODE_SEND_RATE * i++); }, Scheduler::Pipeline::MAIN, NODE_SEND_RATE * i++);
} }
@ -372,12 +372,12 @@ namespace Components
Command::Add("listnodes", [](Command::Params*) Command::Add("listnodes", [](Command::Params*)
{ {
Logger::Print("Nodes: %d\n", Node::Nodes.size()); Logger::Print("Nodes: {}\n", Node::Nodes.size());
std::lock_guard<std::recursive_mutex> _(Node::Mutex); std::lock_guard<std::recursive_mutex> _(Node::Mutex);
for (auto& node : Node::Nodes) for (auto& node : Node::Nodes)
{ {
Logger::Print("%s\t(%s)\n", node.address.getCString(), node.isValid() ? "Valid" : "Invalid"); Logger::Print("{}\t({})\n", node.address.getCString(), node.isValid() ? "Valid" : "Invalid");
} }
}); });

View File

@ -4,12 +4,6 @@
#define NODE_MAX_NODES_TO_SEND 64 #define NODE_MAX_NODES_TO_SEND 64
#define NODE_SEND_RATE 500ms #define NODE_SEND_RATE 500ms
#ifdef NODE_LOG_MESSAGES
#define NODE_LOG(x, ...) Logger::Print(x, __VA_ARGS__)
#else
#define NODE_LOG(x, ...)
#endif
namespace Components namespace Components
{ {
class Node : public Component class Node : public Component

View File

@ -106,7 +106,7 @@ namespace Components
Party::Container.target.setIP(*Game::localIP); Party::Container.target.setIP(*Game::localIP);
Party::Container.target.setType(Game::netadrtype_t::NA_IP); Party::Container.target.setType(Game::netadrtype_t::NA_IP);
Logger::Print("Trying to connect to party with loopback address, using a local ip instead: %s\n", Party::Container.target.getCString()); Logger::Print("Trying to connect to party with loopback address, using a local ip instead: {}\n", Party::Container.target.getCString());
} }
else else
{ {

View File

@ -26,13 +26,13 @@ namespace Components
if (playlist.exists()) if (playlist.exists())
{ {
Logger::Print("Parsing playlist '%s'...\n", playlist.getName().data()); Logger::Print("Parsing playlist '{}'...\n", playlist.getName());
Game::Playlist_ParsePlaylists(playlist.getBuffer().data()); Game::Playlist_ParsePlaylists(playlist.getBuffer().data());
Utils::Hook::Set<bool>(0x1AD3680, true); // Playlist loaded Utils::Hook::Set<bool>(0x1AD3680, true); // Playlist loaded
} }
else else
{ {
Logger::Print("Unable to load playlist '%s'!\n", playlist.getName().data()); Logger::Print("Unable to load playlist '{}'!\n", playlist.getName());
} }
} }

View File

@ -741,7 +741,7 @@ namespace Components
} }
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() - startTime).count(); auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() - startTime).count();
Logger::Print("took %llims\n", duration); Logger::Print("took {}ms\n", duration);
printf("Testing ZLib compression..."); printf("Testing ZLib compression...");

View File

@ -90,7 +90,7 @@ namespace Components
const auto pos = data.find_first_of(' '); const auto pos = data.find_first_of(' ');
if (pos == std::string::npos) if (pos == std::string::npos)
{ {
Logger::Print(Game::CON_CHANNEL_NETWORK, "Invalid RCon request from %s\n", address.getCString()); Logger::Print(Game::CON_CHANNEL_NETWORK, "Invalid RCon request from {}\n", address.getCString());
return; return;
} }
@ -108,7 +108,7 @@ namespace Components
if (svPassword.empty()) if (svPassword.empty())
{ {
Logger::Print(Game::CON_CHANNEL_NETWORK, "RCon request from %s dropped. No password set!\n", address.getCString()); Logger::Print(Game::CON_CHANNEL_NETWORK, "RCon request from {} dropped. No password set!\n", address.getCString());
return; return;
} }
@ -121,7 +121,7 @@ namespace Components
if (RCon::RconLogRequests.get<bool>()) if (RCon::RconLogRequests.get<bool>())
#endif #endif
{ {
Logger::Print(Game::CON_CHANNEL_NETWORK, "Executing RCon request from %s: %s\n", address.getCString(), command.data()); Logger::Print(Game::CON_CHANNEL_NETWORK, "Executing RCon request from {}: {}\n", address.getCString(), command);
} }
Logger::PipeOutput([](const std::string& output) Logger::PipeOutput([](const std::string& output)
@ -138,7 +138,7 @@ namespace Components
} }
else else
{ {
Logger::Print(Game::CON_CHANNEL_NETWORK, "Invalid RCon password sent from %s\n", address.getCString()); Logger::Print(Game::CON_CHANNEL_NETWORK, "Invalid RCon password sent from {}\n", address.getCString());
} }
}); });

View File

@ -34,7 +34,7 @@ namespace Components
if (file.exists()) if (file.exists())
{ {
Utils::IO::WriteFile("raw/" + file.getName(), file.getBuffer()); Utils::IO::WriteFile("raw/" + file.getName(), file.getBuffer());
Logger::Print("File '%s' written to raw!\n", file.getName().data()); Logger::Print("File '{}' written to raw!\n", file.getName());
return; return;
} }
@ -43,11 +43,11 @@ namespace Components
if (data) if (data)
{ {
Utils::IO::WriteFile("raw/" + file.getName(), data); Utils::IO::WriteFile("raw/" + file.getName(), data);
Logger::Print("File '%s' written to raw!\n", file.getName().data()); Logger::Print("File '{}' written to raw!\n", file.getName());
} }
else else
{ {
Logger::Print("File '%s' does not exist!\n", file.getName().data()); Logger::Print("File '{}' does not exist!\n", file.getName());
} }
}); });
} }

View File

@ -111,9 +111,7 @@ namespace Components
{ {
if (Window::GetWindow() && RawMouse::M_RawInput.get<bool>()) if (Window::GetWindow() && RawMouse::M_RawInput.get<bool>())
{ {
#ifdef DEBUG Logger::Debug("Raw Mouse Init");
Logger::Print("Raw Mouse Init.\n");
#endif
RAWINPUTDEVICE Rid[1]; RAWINPUTDEVICE Rid[1];
Rid[0].usUsagePage = 0x01; // HID_USAGE_PAGE_GENERIC Rid[0].usUsagePage = 0x01; // HID_USAGE_PAGE_GENERIC

View File

@ -119,7 +119,7 @@ namespace Components
void Renderer::R_TextureFromCodeError(const char* sampler, Game::GfxCmdBufState* state) void Renderer::R_TextureFromCodeError(const char* sampler, Game::GfxCmdBufState* state)
{ {
Game::Com_Error(Game::ERR_FATAL, "Tried to use sampler '%s' when it isn't valid for material '%s' and technique '%s'", Logger::Error(Game::ERR_FATAL, "Tried to use sampler '{}' when it isn't valid for material '{}' and technique '{}'",
sampler, state->material->info.name, state->technique->name); sampler, state->material->info.name, state->technique->name);
} }
@ -128,25 +128,19 @@ namespace Components
__asm __asm
{ {
// original code // original code
mov eax, DWORD PTR[eax * 4 + 0066E600Ch]; mov eax, dword ptr [eax * 4 + 0x66E600C]
// store GfxCmdBufContext
/*push edx;
mov edx, [esp + 24h];
mov gfxState, edx;
pop edx;*/
// show error // show error
pushad; pushad
push[esp + 24h + 20h]; push [esp + 0x24 + 0x20]
push eax; push eax
call R_TextureFromCodeError; call R_TextureFromCodeError
add esp, 8; add esp, 8
popad; popad
// go back // go back
push 0x0054CAC1; push 0x54CAC1
retn; retn
} }
} }
@ -155,19 +149,19 @@ namespace Components
__asm __asm
{ {
// original code // original code
mov edx, DWORD PTR[eax * 4 + 0066E600Ch]; mov edx, dword ptr [eax * 4 + 0x66E600C]
// show error // show error
pushad; pushad
push ebx; push ebx
push edx; push edx
call R_TextureFromCodeError; call R_TextureFromCodeError
add esp, 8; add esp, 8
popad; popad
// go back // go back
push 0x0054CFA4; push 0x54CFA4
retn; retn
} }
} }
@ -318,8 +312,8 @@ namespace Components
scene->sceneDObj[i].cull.bounds.halfSize[1] < 0 || scene->sceneDObj[i].cull.bounds.halfSize[1] < 0 ||
scene->sceneDObj[i].cull.bounds.halfSize[2] < 0) scene->sceneDObj[i].cull.bounds.halfSize[2] < 0)
{ {
Logger::Warning(Game::CON_CHANNEL_DONT_FILTER, "Negative half size for DOBJ {}, this will cause culling issues!",
Components::Logger::Print("WARNING: Negative half size for DOBJ %s, this will cause culling issues!", scene->sceneDObj[i].obj->models[0]->name); scene->sceneDObj[i].obj->models[0]->name);
} }
Game::R_AddDebugBounds(dobjsColor, &scene->sceneDObj[i].cull.bounds); Game::R_AddDebugBounds(dobjsColor, &scene->sceneDObj[i].cull.bounds);

View File

@ -22,12 +22,12 @@ namespace Components
Game::Scr_ShutdownAllocNode(); Game::Scr_ShutdownAllocNode();
Logger::Print(23, "\n"); Logger::Print(Game::CON_CHANNEL_PARSERSCRIPT, "\n");
Logger::Print(23, "******* script compile error *******\n"); Logger::Print(Game::CON_CHANNEL_PARSERSCRIPT, "******* script compile error *******\n");
Logger::Print(23, "Error: unknown function %s in %s\n", funcName, Script::ScriptName.data()); Logger::Print(Game::CON_CHANNEL_PARSERSCRIPT, "Error: unknown function {} in {}\n", funcName, Script::ScriptName);
Logger::Print(23, "************************************\n"); Logger::Print(Game::CON_CHANNEL_PARSERSCRIPT, "************************************\n");
Logger::Error(Game::ERR_SCRIPT_DROP, "script compile error\nunknown function %s\n%s\n\n", funcName, Script::ScriptName.data()); Logger::Error(Game::ERR_SCRIPT_DROP, "script compile error\nunknown function {}\n{}\n\n", funcName, Script::ScriptName);
} }
__declspec(naked) void Script::StoreFunctionNameStub() __declspec(naked) void Script::StoreFunctionNameStub()
@ -60,11 +60,11 @@ namespace Components
// scrVmPub.debugCode seems to be always false // scrVmPub.debugCode seems to be always false
if (Game::scrVmPub->debugCode || Game::scrVarPub->developer_script) if (Game::scrVmPub->debugCode || Game::scrVarPub->developer_script)
{ {
Game::RuntimeErrorInternal(23, codePos, index, msg); Game::RuntimeErrorInternal(Game::CON_CHANNEL_PARSERSCRIPT, codePos, index, msg);
} }
else else
{ {
Logger::Print(23, "%s\n", msg); Logger::Print(Game::CON_CHANNEL_PARSERSCRIPT, "{}\n", msg);
} }
// Let's not throw error unless we have to // Let's not throw error unless we have to
@ -73,7 +73,7 @@ namespace Components
if (dialogMessage == nullptr) if (dialogMessage == nullptr)
dialogMessage = ""; dialogMessage = "";
Logger::Error(Game::ERR_SCRIPT_DROP, "\x15script runtime error\n(see console for details)\n%s\n%s", msg, dialogMessage); Logger::Error(Game::ERR_SCRIPT_DROP, "\x15script runtime error\n(see console for details)\n{}\n{}", msg, dialogMessage);
} }
} }
@ -168,19 +168,19 @@ namespace Components
} }
} }
Logger::Print(23, "in file %s, line %d:", filename, line); Logger::Print(Game::CON_CHANNEL_PARSERSCRIPT, "in file {}, line {}:", filename, line);
Logger::Print(23, "%s\n", buffer.data() + lineOffset); Logger::Print(Game::CON_CHANNEL_PARSERSCRIPT, "{}\n", buffer.substr(lineOffset));
for (auto i = 0; i < (inlineOffset - 1); ++i) for (auto i = 0; i < (inlineOffset - 1); ++i)
{ {
Logger::Print(23, " "); Logger::Print(Game::CON_CHANNEL_PARSERSCRIPT, " ");
} }
Logger::Print(23, "*\n"); Logger::Print(Game::CON_CHANNEL_PARSERSCRIPT, "*\n");
} }
else else
{ {
Logger::Print(23, "in file %s, offset %d\n", filename, offset); Logger::Print(Game::CON_CHANNEL_PARSERSCRIPT, "in file {}, offset {}\n", filename, offset);
} }
} }
@ -194,38 +194,38 @@ namespace Components
Game::Scr_ShutdownAllocNode(); Game::Scr_ShutdownAllocNode();
Logger::Print(23, "\n"); Logger::Print(Game::CON_CHANNEL_PARSERSCRIPT, "\n");
Logger::Print(23, "******* script compile error *******\n"); Logger::Print(Game::CON_CHANNEL_PARSERSCRIPT, "******* script compile error *******\n");
Logger::Print(23, "Error: %s ", msgbuf); Logger::Print(Game::CON_CHANNEL_PARSERSCRIPT, "Error: {} ", msgbuf);
Script::PrintSourcePos(Script::ScriptName.data(), offset); Script::PrintSourcePos(Script::ScriptName.data(), offset);
Logger::Print(23, "************************************\n\n"); Logger::Print(Game::CON_CHANNEL_PARSERSCRIPT, "************************************\n\n");
Logger::Error(Game::ERR_SCRIPT_DROP, "script compile error\n%s\n%s\n(see console for actual details)\n", msgbuf, Script::ScriptName.data()); Logger::Error(Game::ERR_SCRIPT_DROP, "script compile error\n{}\n{}\n(see console for actual details)\n", msgbuf, Script::ScriptName);
} }
int Script::LoadScriptAndLabel(const std::string& script, const std::string& label) int Script::LoadScriptAndLabel(const std::string& script, const std::string& label)
{ {
Logger::Print("Loading script %s.gsc...\n", script.data()); Logger::Print("Loading script {}.gsc...\n", script);
if (!Game::Scr_LoadScript(script.data())) if (!Game::Scr_LoadScript(script.data()))
{ {
Logger::Print("Script %s encountered an error while loading. (doesn't exist?)", script.data()); Logger::Print("Script {} encountered an error while loading. (doesn't exist?)", script);
Logger::Error(Game::ERR_DROP, reinterpret_cast<const char*>(0x70B810), script.data()); Logger::Error(Game::ERR_DROP, "Could not find script '{}'", script);
} }
else else
{ {
Logger::Print("Script %s.gsc loaded successfully.\n", script.data()); Logger::Print("Script {}.gsc loaded successfully.\n", script);
} }
Logger::Print("Finding script handle %s::%s...\n", script.data(), label.data()); Logger::DebugInfo("Finding script handle {}::{}...", script.data(), label.data());
const auto handle = Game::Scr_GetFunctionHandle(script.data(), label.data()); const auto handle = Game::Scr_GetFunctionHandle(script.data(), label.data());
if (handle) if (handle)
{ {
Logger::Print("Script handle %s::%s loaded successfully.\n", script.data(), label.data()); Logger::Print("Script handle {}::{} loaded successfully.\n", script, label);
return handle; return handle;
} }
Logger::Print("Script handle %s::%s couldn't be loaded. (file with no entry point?)\n", script.data(), label.data()); Logger::Print("Script handle {}::{} couldn't be loaded. (file with no entry point?)\n", script, label);
return handle; return handle;
} }
@ -372,8 +372,8 @@ namespace Components
if (bestCodePos == -1) if (bestCodePos == -1)
return; return;
Logger::Print(23, "\n@ %d (%d - %d)\n", scriptPos, bestCodePos, nextCodePos); Logger::Print(Game::CON_CHANNEL_PARSERSCRIPT, "\n@ {} ({} - {})\n", scriptPos, bestCodePos, nextCodePos);
Logger::Print(23, "in %s (%.1f%% through the source)\n\n", file.data(), ((offset * 100.0f) / (nextCodePos - bestCodePos))); Logger::Print(Game::CON_CHANNEL_PARSERSCRIPT, "in {} ({} through the source)\n\n", file, ((offset * 100.0f) / (nextCodePos - bestCodePos)));
} }
__declspec(naked) void Script::Scr_PrintPrevCodePosStub() __declspec(naked) void Script::Scr_PrintPrevCodePosStub()
@ -471,13 +471,13 @@ namespace Components
{ {
if (what[0] == '\0' || with[0] == '\0') if (what[0] == '\0' || with[0] == '\0')
{ {
Logger::Print("Warning: Invalid parameters passed to ReplacedFunctions\n"); Logger::Warning(Game::CON_CHANNEL_SCRIPT, "Invalid parameters passed to ReplacedFunctions\n");
return; return;
} }
if (Script::ReplacedFunctions.contains(what)) if (Script::ReplacedFunctions.contains(what))
{ {
Logger::Print("Warning: ReplacedFunctions already contains codePosValue for a function\n"); Logger::Warning(Game::CON_CHANNEL_SCRIPT, "ReplacedFunctions already contains codePosValue for a function\n");
} }
Script::ReplacedFunctions[what] = with; Script::ReplacedFunctions[what] = with;
@ -589,9 +589,9 @@ namespace Components
// Allow printing to the console even when developer is 0 // Allow printing to the console even when developer is 0
Script::AddFunction("PrintConsole", [] // gsc: PrintConsole(<string>) Script::AddFunction("PrintConsole", [] // gsc: PrintConsole(<string>)
{ {
for (auto i = 0u; i < Game::Scr_GetNumParam(); i++) for (std::size_t i = 0; i < Game::Scr_GetNumParam(); ++i)
{ {
const auto str = Game::Scr_GetString(i); const auto* str = Game::Scr_GetString(i);
if (str == nullptr) if (str == nullptr)
{ {
@ -599,7 +599,7 @@ namespace Components
return; return;
} }
Logger::Print(Game::level->scriptPrintChannel, "%s", str); Logger::Print(Game::level->scriptPrintChannel, "{}", str);
} }
}); });
@ -731,7 +731,7 @@ namespace Components
const auto timeTaken = static_cast<int>((nowMs - Script::LastFrameTime) * timeScale); const auto timeTaken = static_cast<int>((nowMs - Script::LastFrameTime) * timeScale);
if (timeTaken >= 500) if (timeTaken >= 500)
Logger::Print(23, "Hitch warning: %i msec frame time\n", timeTaken); Logger::Print(Game::CON_CHANNEL_PARSERSCRIPT, "Hitch warning: {} msec frame time\n", timeTaken);
} }
Script::LastFrameTime = nowMs; Script::LastFrameTime = nowMs;

View File

@ -49,7 +49,7 @@ namespace Components
// If it's a command don't execute it // If it's a command don't execute it
if (Command::Find(name) != nullptr) if (Command::Find(name) != nullptr)
{ {
Logger::Print(0, "CL_SelectStringTableEntryInDvar_f: parameter is a command\n"); Logger::DebugInfo("CL_SelectStringTableEntryInDvar_f: parameter is a command\n");
return; return;
} }
@ -67,7 +67,7 @@ namespace Components
// If it's a dvar check that it does not have disallowed flags // If it's a dvar check that it does not have disallowed flags
if ((dvar->flags & disallowedFlags) != 0) if ((dvar->flags & disallowedFlags) != 0)
{ {
Logger::Print(0, "CL_SelectStringTableEntryInDvar_f: parameter is a protected dvar\n"); Logger::DebugInfo("CL_SelectStringTableEntryInDvar_f: parameter is a protected dvar\n");
return; return;
} }
} }
@ -107,6 +107,7 @@ namespace Components
if (static_cast<std::size_t>(net_message->cursize) >= sizeof(Game::DeferredMsg::data)) if (static_cast<std::size_t>(net_message->cursize) >= sizeof(Game::DeferredMsg::data))
{ {
Logger::DebugInfo("Dropping net_message. Size is {}", net_message->cursize);
return; return;
} }
@ -132,7 +133,7 @@ namespace Components
Utils::Hook::Nop(0x41698E, 5); // Disable Svcmd_EntityList_f Utils::Hook::Nop(0x41698E, 5); // Disable Svcmd_EntityList_f
// Patch selectStringTableEntryInDvar // Patch selectStringTableEntryInDvar
Utils::Hook::Set<void(*)()>(0x405959, Security::SelectStringTableEntryInDvarStub); Utils::Hook::Set<void(*)()>(0x405959, SelectStringTableEntryInDvarStub);
// Patch G_GetClientScore for uninitialized game // Patch G_GetClientScore for uninitialized game
Utils::Hook(0x469AC0, G_GetClientScore, HOOK_JUMP).install()->quick(); Utils::Hook(0x469AC0, G_GetClientScore, HOOK_JUMP).install()->quick();

View File

@ -287,7 +287,7 @@ namespace Components
Game::netadr_t masterServerAddr; Game::netadr_t masterServerAddr;
if (!ServerList::GetMasterServer(masterServerName, masterPort, masterServerAddr)) if (!ServerList::GetMasterServer(masterServerName, masterPort, masterServerAddr))
{ {
Logger::Print("Could not resolve address for %s:%u", masterServerName, masterPort); Logger::Print("Could not resolve address for {}:{}", masterServerName, masterPort);
Toast::Show("cardicon_headshot", "^1Error", Utils::String::VA("Could not resolve address for %s:%u", masterServerName, masterPort), 5000); Toast::Show("cardicon_headshot", "^1Error", Utils::String::VA("Could not resolve address for %s:%u", masterServerName, masterPort), 5000);
return; return;
} }
@ -659,7 +659,7 @@ namespace Components
{ {
ServerList::RefreshContainer.awatingList = false; ServerList::RefreshContainer.awatingList = false;
Logger::Print("We haven't received a response from the master within %d seconds!\n", (Game::Sys_Milliseconds() - ServerList::RefreshContainer.awaitTime) / 1000); Logger::Print("We haven't received a response from the master within {} seconds!\n", (Game::Sys_Milliseconds() - ServerList::RefreshContainer.awaitTime) / 1000);
Toast::Show("cardicon_headshot", "^1Error", "Failed to reach master server, using node servers instead.", 5000); Toast::Show("cardicon_headshot", "^1Error", "Failed to reach master server, using node servers instead.", 5000);
useMasterServer = false; useMasterServer = false;
@ -823,7 +823,7 @@ namespace Components
ServerList::InsertRequest(serverAddr); ServerList::InsertRequest(serverAddr);
} }
Logger::Print("Parsed %d servers from master\n", ServerList::RefreshContainer.servers.size() - count); Logger::Print("Parsed {} servers from master\n", ServerList::RefreshContainer.servers.size() - count);
}); });
// Set default masterServerName + port and save it // Set default masterServerName + port and save it
@ -864,7 +864,7 @@ namespace Components
ServerList::SortAsc = true; ServerList::SortAsc = true;
} }
Logger::Print("Sorting server list by token: %d\n", ServerList::SortKey); Logger::Print("Sorting server list by token: {}\n", ServerList::SortKey);
ServerList::SortList(); ServerList::SortList();
}); });
@ -914,7 +914,7 @@ namespace Components
count += server.clients; count += server.clients;
} }
Logger::Print("There are %d players playing.\n", count); Logger::DebugInfo("There are %d players playing", count);
}); });
#endif #endif
// Add required ownerDraws // Add required ownerDraws

View File

@ -53,7 +53,7 @@ namespace Components
{ {
value = *i; value = *i;
dataVector.erase(i); dataVector.erase(i);
Logger::Print("Playerdatadef entry '%s' will be rebased!\n", value); Logger::Print("Playerdatadef entry '{}' will be rebased!\n", value);
break; break;
} }
} }
@ -182,13 +182,13 @@ namespace Components
if (data->defCount != 1) if (data->defCount != 1)
{ {
Logger::Error("PlayerDataDefSet contains more than 1 definition!"); Logger::Error(Game::ERR_FATAL, "PlayerDataDefSet contains more than 1 definition!");
return; return;
} }
if (data->defs[0].version != 155) if (data->defs[0].version != 155)
{ {
Logger::Error("Initial PlayerDataDef is not version 155, patching not possible!"); Logger::Error(Game::ERR_FATAL, "Initial PlayerDataDef is not version 155, patching not possible!");
return; return;
} }
@ -209,17 +209,17 @@ namespace Components
if (!errors.empty()) if (!errors.empty())
{ {
Logger::Error("Parsing patch file '%s' for PlayerDataDef version %d failed: %s", definition.getName().data(), i, errors.data()); Logger::Error(Game::ERR_FATAL, "Parsing patch file '{}' for PlayerDataDef version {} failed: {}", definition.getName(), i, errors);
return; return;
} }
if (!defData.is_object()) if (!defData.is_object())
{ {
Logger::Error("PlayerDataDef patch for version %d is invalid!", i); Logger::Error(Game::ERR_FATAL, "PlayerDataDef patch for version {} is invalid!", i);
return; return;
} }
for (unsigned int pType = 0; pType < StructuredData::PlayerDataType::ENUM_MAX; ++pType) for (std::size_t pType = 0; pType < StructuredData::PlayerDataType::ENUM_MAX; ++pType)
{ {
auto enumData = defData[StructuredData::EnumTranslation[pType]]; auto enumData = defData[StructuredData::EnumTranslation[pType]];
@ -293,7 +293,7 @@ namespace Components
// Invalid patch data // Invalid patch data
if (patchData.size() != StructuredData::PlayerDataType::ENUM_MAX) if (patchData.size() != StructuredData::PlayerDataType::ENUM_MAX)
{ {
Logger::Error("PlayerDataDef patch for version %d wasn't parsed correctly!", newData[i].version); Logger::Error(Game::ERR_FATAL, "PlayerDataDef patch for version {} wasn't parsed correctly!", newData[i].version);
continue; continue;
} }

View File

@ -762,7 +762,7 @@ namespace Components
if(strcmp(material->techniqueSet->name, "2d") != 0) if(strcmp(material->techniqueSet->name, "2d") != 0)
{ {
Logger::Print("^1Fonticon material '%s' does not have 2d techset!\n", material->info.name); Logger::Print("^1Fonticon material '{}' does not have 2d techset!\n", material->info.name);
material = Game::DB_FindXAssetHeader(Game::ASSET_TYPE_MATERIAL, "default").material; material = Game::DB_FindXAssetHeader(Game::ASSET_TYPE_MATERIAL, "default").material;
} }

View File

@ -223,7 +223,7 @@ namespace Components
{ {
Theatre::DemoInfo info = Theatre::Demos[Theatre::CurrentSelection]; Theatre::DemoInfo info = Theatre::Demos[Theatre::CurrentSelection];
Logger::Print("Deleting demo %s...\n", info.name.data()); Logger::Print("Deleting demo {}...\n", info.name);
FileSystem::DeleteFile("demos", info.name + ".dm_13"); FileSystem::DeleteFile("demos", info.name + ".dm_13");
FileSystem::DeleteFile("demos", info.name + ".dm_13.json"); FileSystem::DeleteFile("demos", info.name + ".dm_13.json");
@ -308,7 +308,7 @@ namespace Components
for (int i = 0; i < numDel; ++i) for (int i = 0; i < numDel; ++i)
{ {
Logger::Print("Deleting old demo %s\n", files[i].data()); Logger::Print("Deleting old demo {}\n", files[i]);
FileSystem::DeleteFile("demos", files[i].data()); FileSystem::DeleteFile("demos", files[i].data());
FileSystem::DeleteFile("demos", Utils::String::VA("%s.json", files[i].data())); FileSystem::DeleteFile("demos", Utils::String::VA("%s.json", files[i].data()));
} }

View File

@ -48,6 +48,12 @@ namespace Components
const auto* ent = Game::GetPlayerEntity(entref); const auto* ent = Game::GetPlayerEntity(entref);
const auto* name = Game::Scr_GetString(0); const auto* name = Game::Scr_GetString(0);
if (name == nullptr)
{
Game::Scr_ParamError(0, "^1SetName: Illegal parameter!\n");
}
Logger::DebugInfo("Setting name of {} to {}", ent->s.number, name);
UserInfoOverrides[ent->s.number]["name"] = name; UserInfoOverrides[ent->s.number]["name"] = name;
Game::ClientUserinfoChanged(ent->s.number); Game::ClientUserinfoChanged(ent->s.number);
}); });
@ -56,6 +62,7 @@ namespace Components
{ {
const auto* ent = Game::GetPlayerEntity(entref); const auto* ent = Game::GetPlayerEntity(entref);
Logger::DebugInfo("Resetting name of {} ", ent->s.number);
UserInfoOverrides[ent->s.number].erase("name"); UserInfoOverrides[ent->s.number].erase("name");
Game::ClientUserinfoChanged(ent->s.number); Game::ClientUserinfoChanged(ent->s.number);
}); });

View File

@ -47,8 +47,7 @@ namespace Components
if (input == end) if (input == end)
{ {
Logger::Print("Warning: %s is not a valid input\n" Logger::Warning(Game::CON_CHANNEL_DONT_FILTER, "{} is not a valid input\nUsage: {} <weapon index>\n",
"Usage: %s <weapon index>\n",
input, params.get(0)); input, params.get(0));
return 0; return 0;
} }

View File

@ -46,7 +46,7 @@ namespace Components
if (!found) if (!found)
{ {
Logger::Print("Asset %s of type %s was loaded, but not written!", name.data(), Game::DB_GetXAssetTypeName(subAsset.type)); Logger::Print("Asset {} of type {} was loaded, but not written!", name, Game::DB_GetXAssetTypeName(subAsset.type));
} }
} }
@ -66,7 +66,7 @@ namespace Components
if (!found) if (!found)
{ {
Logger::Error("Asset %s of type %s was written, but not loaded!", name.data(), Game::DB_GetXAssetTypeName(alias.first.type)); Logger::Error(Game::ERR_FATAL, "Asset {} of type {} was written, but not loaded!", name, Game::DB_GetXAssetTypeName(alias.first.type));
} }
} }
#endif #endif
@ -97,7 +97,7 @@ namespace Components
{ {
if(!this->dataMap.isValid()) if(!this->dataMap.isValid())
{ {
Logger::Print("Unable to load CSV for '%s'!\n", this->zoneName.data()); Logger::Print("Unable to load CSV for '{}'!\n", this->zoneName);
return; return;
} }
@ -113,7 +113,7 @@ namespace Components
if(this->buffer.hasBlock()) if(this->buffer.hasBlock())
{ {
Logger::Error("Non-popped blocks left!\n"); Logger::Error(Game::ERR_FATAL, "Non-popped blocks left!\n");
} }
Logger::Print("Compressing...\n"); Logger::Print("Compressing...\n");
@ -141,7 +141,7 @@ namespace Components
} }
else else
{ {
Logger::Print("Zone '%s' already loaded\n", fastfile.data()); Logger::Print("Zone '{}' already loaded\n", fastfile);
} }
} }
} }
@ -175,7 +175,8 @@ namespace Components
} }
else else
{ {
Logger::Error("Unable to rename '%s' to '%s' as the asset type '%s' is invalid!", oldName.data(), newName.data(), typeName.data()); Logger::Error(Game::ERR_FATAL, "Unable to rename '{}' to '{}' as the asset type '{}' is invalid!",
oldName, newName, typeName);
} }
} }
} }
@ -209,8 +210,11 @@ namespace Components
{ {
Game::XAssetType type = Game::DB_GetXAssetNameType(typeName.data()); Game::XAssetType type = Game::DB_GetXAssetNameType(typeName.data());
if (name.find(" ", 0) != std::string::npos) if (name.find(" ", 0) != std::string::npos)
Logger::Print("Warning: asset with name '%s' contains spaces. Check your zone source file to ensure this is correct!\n", name.data()); {
Logger::Warning(Game::CON_CHANNEL_DONT_FILTER,
"Asset with name '{}' contains spaces. Check your zone source file to ensure this is correct!\n", name);
}
// Sanitize name for empty assets // Sanitize name for empty assets
if (name[0] == ',') name.erase(name.begin()); if (name[0] == ',') name.erase(name.begin());
@ -219,7 +223,7 @@ namespace Components
if (type == Game::XAssetType::ASSET_TYPE_INVALID || type >= Game::XAssetType::ASSET_TYPE_COUNT) if (type == Game::XAssetType::ASSET_TYPE_INVALID || type >= Game::XAssetType::ASSET_TYPE_COUNT)
{ {
Logger::Error("Error: Invalid asset type '%s'\n", typeName.data()); Logger::Error(Game::ERR_FATAL, "Invalid asset type '{}'\n", typeName);
return false; return false;
} }
@ -227,7 +231,7 @@ namespace Components
if (!assetHeader.data) if (!assetHeader.data)
{ {
Logger::Error("Error: Missing asset '%s' of type '%s'\n", name.data(), Game::DB_GetXAssetTypeName(type)); Logger::Error(Game::ERR_FATAL, "Missing asset '{}' of type '{}'\n", name, Game::DB_GetXAssetTypeName(type));
return false; return false;
} }
@ -341,12 +345,10 @@ namespace Components
asset.header = this->findSubAsset(type, name); asset.header = this->findSubAsset(type, name);
if (!asset.header.data) if (!asset.header.data)
{ {
Logger::Error("Missing required asset '%s' (%s). Export failed!", name.data(), Game::DB_GetXAssetTypeName(type)); Logger::Error(Game::ERR_FATAL, "Missing required asset '{}' ({}). Export failed!", name, Game::DB_GetXAssetTypeName(type));
} }
#ifdef DEBUG Logger::DebugInfo("Saving require ({}): {}\n", Game::DB_GetXAssetTypeName(type), Game::DB_GetXAssetNameHandlers[type](&header));
Components::Logger::Print("Saving require (%s): %s\n", Game::DB_GetXAssetTypeName(type), Game::DB_GetXAssetNameHandlers[type](&header));
#endif
// we alias the next 4 (aligned) bytes of the stream b/c DB_InsertPointer gives us a nice pointer to use as the alias // we alias the next 4 (aligned) bytes of the stream b/c DB_InsertPointer gives us a nice pointer to use as the alias
// otherwise it would be a fuckfest trying to figure out where the alias is in the stream // otherwise it would be a fuckfest trying to figure out where the alias is in the stream
@ -413,7 +415,7 @@ namespace Components
} }
#endif #endif
Utils::IO::WriteFile("uncompressed", zoneBuffer); Utils::IO::WriteFile("uncompressed", zoneBuffer);
zoneBuffer = Utils::Compression::ZLib::Compress(zoneBuffer); zoneBuffer = Utils::Compression::ZLib::Compress(zoneBuffer);
outBuffer.append(zoneBuffer); outBuffer.append(zoneBuffer);
@ -422,7 +424,8 @@ namespace Components
Utils::IO::WriteFile(outFile, outBuffer); Utils::IO::WriteFile(outFile, outBuffer);
Logger::Print("done.\n"); Logger::Print("done.\n");
Logger::Print("Zone '%s' written with %d assets and %d script strings\n", outFile.data(), (this->aliasList.size() + this->loadedAssets.size()), this->scriptStrings.size()); Logger::Print("Zone '{}' written with {} assets and {} script strings\n",
outFile, (this->aliasList.size() + this->loadedAssets.size()), this->scriptStrings.size());
} }
void ZoneBuilder::Zone::saveData() void ZoneBuilder::Zone::saveData()
@ -446,10 +449,11 @@ namespace Components
// Write ScriptStrings, if available // Write ScriptStrings, if available
if (!this->scriptStrings.empty()) if (!this->scriptStrings.empty())
{ {
this->buffer.saveNull(4); // Empty script string? this->buffer.saveNull(4);
// This actually represents a NULL string, but as scriptString. // Empty script string?
// So scriptString loading for NULL scriptStrings from fastfile results in a NULL scriptString. // This actually represents a NULL string, but as scriptString.
// That's the reason why the count is incremented by 1, if scriptStrings are available. // So scriptString loading for NULL scriptStrings from fastfile results in a NULL scriptString.
// That's the reason why the count is incremented by 1, if scriptStrings are available.
// Write ScriptString pointer table // Write ScriptString pointer table
for (size_t i = 0; i < this->scriptStrings.size(); ++i) for (size_t i = 0; i < this->scriptStrings.size(); ++i)
@ -485,9 +489,8 @@ namespace Components
this->buffer.pushBlock(Game::XFILE_BLOCK_TEMP); this->buffer.pushBlock(Game::XFILE_BLOCK_TEMP);
this->buffer.align(Utils::Stream::ALIGN_4); this->buffer.align(Utils::Stream::ALIGN_4);
#ifdef DEBUG Logger::DebugInfo("Saving ({}): {}",
Components::Logger::Print("Saving (%s): %s\n", Game::DB_GetXAssetTypeName(asset.type), Game::DB_GetXAssetNameHandlers[asset.type](&asset.header)); Game::DB_GetXAssetTypeName(asset.type), Game::DB_GetXAssetNameHandlers[asset.type](&asset.header));
#endif
this->store(asset.header); this->store(asset.header);
AssetHandler::ZoneSave(asset, this); AssetHandler::ZoneSave(asset, this);
@ -519,7 +522,7 @@ namespace Components
if (this->findAsset(Game::XAssetType::ASSET_TYPE_RAWFILE, this->branding.name) != -1) if (this->findAsset(Game::XAssetType::ASSET_TYPE_RAWFILE, this->branding.name) != -1)
{ {
Logger::Error("Unable to add branding. Asset '%s' already exists!", this->branding.name); Logger::Error(Game::ERR_FATAL, "Unable to add branding. Asset '{}' already exists!", this->branding.name);
} }
Game::XAssetHeader header = { &this->branding }; Game::XAssetHeader header = { &this->branding };
@ -635,7 +638,7 @@ namespace Components
} }
else else
{ {
Logger::Error("Unable to rename '%s' to '%s' as the asset type is invalid!", asset.data(), newName.data()); Logger::Error(Game::ERR_FATAL, "Unable to rename '{}' to '{}' as the asset type is invalid!", asset, newName);
} }
} }
@ -651,7 +654,7 @@ namespace Components
} }
else else
{ {
Logger::Error("Unable to get name for '%s' as the asset type is invalid!", asset.data()); Logger::Error(Game::ERR_FATAL, "Unable to get name for '{}' as the asset type is invalid!", asset);
} }
return asset; return asset;
@ -709,20 +712,20 @@ namespace Components
if (zoneIndex > 0) if (zoneIndex > 0)
{ {
Game::XAssetEntry* entry = Game::DB_FindXAssetEntry(type, name.data()); Game::XAssetEntry* entry = Game::DB_FindXAssetEntry(type, name.data());
if (entry && entry->zoneIndex == zoneIndex) if (entry && entry->zoneIndex == zoneIndex)
{ {
// Allocate an empty asset (filled with zeros) // Allocate an empty asset (filled with zeros)
header.data = builder->getAllocator()->allocate(Game::DB_GetXAssetSizeHandlers[type]()); header.data = builder->getAllocator()->allocate(Game::DB_GetXAssetSizeHandlers[type]());
// Set the name to the original name, so it can be stored // Set the name to the original name, so it can be stored
Game::DB_SetXAssetNameHandlers[type](&header, name.data()); Game::DB_SetXAssetNameHandlers[type](&header, name.data());
AssetHandler::StoreTemporaryAsset(type, header); AssetHandler::StoreTemporaryAsset(type, header);
// Set the name to the empty name // Set the name to the empty name
Game::DB_SetXAssetNameHandlers[type](&header, builder->getAllocator()->duplicateString("," + name)); Game::DB_SetXAssetNameHandlers[type](&header, builder->getAllocator()->duplicateString("," + name));
} }
} }
} }
@ -844,16 +847,11 @@ namespace Components
} }
}); });
Command::Add("quit", [](Command::Params*) Command::Add("quit", []([[maybe_unused]] Command::Params* params)
{ {
Game::Com_Quitf_t(); Game::Com_Quitf_t();
}); });
Command::Add("error", [](Command::Params*)
{
Game::Com_Error(Game::ERR_FATAL, "This is a test %s\n", "error");
});
// now load default assets and shaders // now load default assets and shaders
if (FastFiles::Exists("defaults") && FastFiles::Exists("techsets")) if (FastFiles::Exists("defaults") && FastFiles::Exists("techsets"))
{ {
@ -861,7 +859,8 @@ namespace Components
} }
else else
{ {
Logger::Print("Warning: Missing new init zones (defaults.ff & techsets.ff). You will need to load fastfiles to manually obtain techsets.\n"); Logger::Warning(Game::CON_CHANNEL_DONT_FILTER,
"Missing new init zones (defaults.ff & techsets.ff). You will need to load fastfiles to manually obtain techsets.\n");
Game::DB_LoadXAssets(baseZones_old, ARRAYSIZE(baseZones_old), 0); Game::DB_LoadXAssets(baseZones_old, ARRAYSIZE(baseZones_old), 0);
} }
@ -875,10 +874,10 @@ namespace Components
// defaults need to load before we do this // defaults need to load before we do this
Utils::Hook::Call<void()>(0x4E1F30)(); // G_SetupWeaponDef Utils::Hook::Call<void()>(0x4E1F30)(); // G_SetupWeaponDef
Utils::Hook::Call<void()>(0x4454C0)(); // Item_SetupKeywordHash (for loading menus) Utils::Hook::Call<void()>(0x4454C0)(); // Item_SetupKeywordHash (for loading menus)
Utils::Hook::Call<void()>(0x501BC0)(); // Menu_SetupKeywordHash (for loading menus) Utils::Hook::Call<void()>(0x501BC0)(); // Menu_SetupKeywordHash (for loading menus)
Utils::Hook::Call<void()>(0x4A1280)(); // something related to uiInfoArray Utils::Hook::Call<void()>(0x4A1280)(); // something related to uiInfoArray
Utils::Hook::Call<void(const char*)>(0x464A90)(GetCommandLineA()); // Com_ParseCommandLine Utils::Hook::Call<void(const char*)>(0x464A90)(GetCommandLineA()); // Com_ParseCommandLine
Utils::Hook::Call<void()>(0x60C3D0)(); // Com_AddStartupCommands Utils::Hook::Call<void()>(0x60C3D0)(); // Com_AddStartupCommands
@ -923,12 +922,13 @@ namespace Components
return 0; return 0;
} }
void ZoneBuilder::HandleError(int level, const char* format, ...) void ZoneBuilder::HandleError(Game::errorParm_t code, const char* fmt, ...)
{ {
char buffer[256] = { 0 }; char buffer[4096] = {0};
va_list args; va_list args;
va_start(args, format); va_start(args, fmt);
vsnprintf_s(buffer, 256, format, args); _vsnprintf_s(buffer, _TRUNCATE, fmt, args);
va_end(args);
if (!Flags::HasFlag("stdout")) if (!Flags::HasFlag("stdout"))
{ {
@ -940,9 +940,10 @@ namespace Components
fflush(stderr); fflush(stderr);
} }
va_end(args); if (code == Game::ERR_FATAL)
{
if (!level) ExitProcess(1); ExitProcess(1);
}
} }
__declspec(naked) void ZoneBuilder::SoftErrorAssetOverflow() __declspec(naked) void ZoneBuilder::SoftErrorAssetOverflow()
@ -1084,8 +1085,8 @@ namespace Components
// set new entry point // set new entry point
Utils::Hook(0x4513DA, ZoneBuilder::EntryPoint, HOOK_JUMP).install()->quick(); Utils::Hook(0x4513DA, ZoneBuilder::EntryPoint, HOOK_JUMP).install()->quick();
// handle com_error calls // handle Com_error Calls
Utils::Hook(0x4B22D0, ZoneBuilder::HandleError, HOOK_JUMP).install()->quick(); Utils::Hook(Game::Com_Error, ZoneBuilder::HandleError, HOOK_JUMP).install()->quick();
// thread fuckery hooks // thread fuckery hooks
Utils::Hook(0x4C37D0, ZoneBuilder::IsThreadMainThreadHook, HOOK_JUMP).install()->quick(); Utils::Hook(0x4C37D0, ZoneBuilder::IsThreadMainThreadHook, HOOK_JUMP).install()->quick();
@ -1104,29 +1105,30 @@ namespace Components
if (!ZoneBuilder::TraceZone.empty() && ZoneBuilder::TraceZone == FastFiles::Current()) if (!ZoneBuilder::TraceZone.empty() && ZoneBuilder::TraceZone == FastFiles::Current())
{ {
ZoneBuilder::TraceAssets.push_back({ type, name }); ZoneBuilder::TraceAssets.push_back({ type, name });
OutputDebugStringA((name + "\n").data()); OutputDebugStringA((name + "\n").data());
} }
}); });
Command::Add("verifyzone", [](Command::Params* params) Command::Add("verifyzone", [](Command::Params* params)
{ {
if (params->size() < 2) return; if (params->size() < 2) return;
/* /*
Utils::Hook(0x4AE9C2, [] { Utils::Hook(0x4AE9C2, []
Game::WeaponCompleteDef** varPtr = (Game::WeaponCompleteDef**)0x112A9F4; {
Game::WeaponCompleteDef* var = *varPtr; Game::WeaponCompleteDef** varPtr = (Game::WeaponCompleteDef**)0x112A9F4;
OutputDebugStringA(""); Game::WeaponCompleteDef* var = *varPtr;
Utils::Hook::Call<void()>(0x4D1D60)(); // DB_PopStreamPos OutputDebugStringA("");
}, HOOK_JUMP).install()->quick(); Utils::Hook::Call<void()>(0x4D1D60)(); // DB_PopStreamPos
}, HOOK_JUMP).install()->quick();
Utils::Hook(0x4AE9B4, []
Utils::Hook(0x4AE9B4, [] { {
Game::WeaponCompleteDef** varPtr = (Game::WeaponCompleteDef**)0x112A9F4; Game::WeaponCompleteDef** varPtr = (Game::WeaponCompleteDef**)0x112A9F4;
Game::WeaponCompleteDef* var = *varPtr; Game::WeaponCompleteDef* var = *varPtr;
OutputDebugStringA(""); OutputDebugStringA("");
Utils::Hook::Call<void()>(0x4D1D60)(); // DB_PopStreamPos Utils::Hook::Call<void()>(0x4D1D60)(); // DB_PopStreamPos
}, HOOK_JUMP).install()->quick(); }, HOOK_JUMP).install()->quick();
*/ */
std::string zone = params->get(1); std::string zone = params->get(1);
@ -1137,14 +1139,14 @@ namespace Components
info.allocFlags = Game::DB_ZONE_MOD; info.allocFlags = Game::DB_ZONE_MOD;
info.freeFlags = 0; info.freeFlags = 0;
Logger::Print("Loading zone '%s'...\n", zone.data()); Logger::Print("Loading zone '{}'...\n", zone);
Game::DB_LoadXAssets(&info, 1, true); Game::DB_LoadXAssets(&info, 1, true);
AssetHandler::FindOriginalAsset(Game::XAssetType::ASSET_TYPE_RAWFILE, zone.data()); // Lock until zone is loaded AssetHandler::FindOriginalAsset(Game::XAssetType::ASSET_TYPE_RAWFILE, zone.data()); // Lock until zone is loaded
auto assets = ZoneBuilder::EndAssetTrace(); auto assets = ZoneBuilder::EndAssetTrace();
Logger::Print("Unloading zone '%s'...\n", zone.data()); Logger::Print("Unloading zone '{}'...\n", zone);
info.freeFlags = Game::DB_ZONE_MOD; info.freeFlags = Game::DB_ZONE_MOD;
info.allocFlags = 0; info.allocFlags = 0;
info.name = nullptr; info.name = nullptr;
@ -1152,12 +1154,12 @@ namespace Components
Game::DB_LoadXAssets(&info, 1, true); Game::DB_LoadXAssets(&info, 1, true);
AssetHandler::FindOriginalAsset(Game::XAssetType::ASSET_TYPE_RAWFILE, "default"); // Lock until zone is unloaded AssetHandler::FindOriginalAsset(Game::XAssetType::ASSET_TYPE_RAWFILE, "default"); // Lock until zone is unloaded
Logger::Print("Zone '%s' loaded with %d assets:\n", zone.data(), assets.size()); Logger::Print("Zone '{}' loaded with {} assets:\n", zone, assets.size());
int count = 0; int count = 0;
for (auto i = assets.begin(); i != assets.end(); ++i, ++count) for (auto i = assets.begin(); i != assets.end(); ++i, ++count)
{ {
Logger::Print(" %d: %s: %s\n", count, Game::DB_GetXAssetTypeName(i->first), i->second.data()); Logger::Print(" {}: {}: {}\n", count, Game::DB_GetXAssetTypeName(i->first), i->second);
} }
Logger::Print("\n"); Logger::Print("\n");
@ -1168,7 +1170,7 @@ namespace Components
if (params->size() < 2) return; if (params->size() < 2) return;
std::string zoneName = params->get(1); std::string zoneName = params->get(1);
Logger::Print("Building zone '%s'...\n", zoneName.data()); Logger::Print("Building zone '{}'...\n", zoneName);
Zone(zoneName).build(); Zone(zoneName).build();
}); });
@ -1219,13 +1221,13 @@ namespace Components
if (Utils::IO::FileExists("zone/techsets/" + zone + "_techsets.ff")) if (Utils::IO::FileExists("zone/techsets/" + zone + "_techsets.ff"))
{ {
Logger::Print("Skipping previously generated zone %s\n", zone.data()); Logger::Print("Skipping previously generated zone {}\n", zone);
continue; continue;
} }
if (zone.find("_load") != std::string::npos) if (zone.find("_load") != std::string::npos)
{ {
Logger::Print("Skipping loadscreen zone %s\n", zone.data()); Logger::Print("Skipping loadscreen zone {}\n", zone);
continue; continue;
} }
@ -1249,7 +1251,7 @@ namespace Components
if (curTechsets_list.size() == 0) if (curTechsets_list.size() == 0)
{ {
Logger::Print("Skipping empty zone %s\n", zone.data()); Logger::Print("Skipping empty zone {}\n", zone);
// unload zone // unload zone
info.name = nullptr; info.name = nullptr;
info.allocFlags = 0x0; info.allocFlags = 0x0;
@ -1278,7 +1280,7 @@ namespace Components
// build the techset zone // build the techset zone
std::string zoneName = "techsets/" + zone + "_techsets"; std::string zoneName = "techsets/" + zone + "_techsets";
Logger::Print("Building zone '%s'...\n", zoneName.data()); Logger::Print("Building zone '{}'...\n", zoneName);
Zone(zoneName).build(); Zone(zoneName).build();
// unload original zone // unload original zone
@ -1326,7 +1328,7 @@ namespace Components
} }
else else
{ {
Logger::Print("Zone '%s' already loaded\n", it.data()); Logger::Print("Zone '{}' already loaded\n", it);
} }
if (i == 20) // cap at 20 just to be safe if (i == 20) // cap at 20 just to be safe
@ -1351,7 +1353,7 @@ namespace Components
Utils::IO::WriteFile(tempZoneFile, csvStr.data()); Utils::IO::WriteFile(tempZoneFile, csvStr.data());
Logger::Print("Building zone '%s'...\n", tempZone.data()); Logger::Print("Building zone '{}'...\n", tempZone);
Zone(tempZone).build(); Zone(tempZone).build();
// unload all zones // unload all zones
@ -1382,7 +1384,7 @@ namespace Components
std::string mat = ZoneBuilder::FindMaterialByTechnique(tech); std::string mat = ZoneBuilder::FindMaterialByTechnique(tech);
if (mat.length() == 0) if (mat.length() == 0)
{ {
Logger::Print("Couldn't find a material for techset %s. Sort Keys will be incorrect.\n", tech.c_str()); Logger::Print("Couldn't find a material for techset {}. Sort Keys will be incorrect.\n", tech);
csvStr.append("techset," + tech + "\n"); csvStr.append("techset," + tech + "\n");
} }
else else
@ -1396,7 +1398,7 @@ namespace Components
Utils::IO::WriteFile(tempZoneFile, csvStr.data()); Utils::IO::WriteFile(tempZoneFile, csvStr.data());
Logger::Print("Building zone '%s'...\n", tempZone.data()); Logger::Print("Building zone '{}'...\n", tempZone);
Zone(tempZone).build(); Zone(tempZone).build();
// unload all zones // unload all zones
@ -1412,7 +1414,7 @@ namespace Components
// build final techsets fastfile // build final techsets fastfile
if (subCount > 24) if (subCount > 24)
{ {
Logger::ErrorPrint(Game::ERR_DROP, "How did you have 576 fastfiles?\n"); Logger::Error(Game::ERR_DROP, "How did you have 576 fastfiles?\n");
} }
curTechsets_list.clear(); curTechsets_list.clear();
@ -1463,7 +1465,7 @@ namespace Components
Game::DB_EnumXAssets(type, [](Game::XAssetHeader header, void* data) Game::DB_EnumXAssets(type, [](Game::XAssetHeader header, void* data)
{ {
Game::XAsset asset = { *reinterpret_cast<Game::XAssetType*>(data), header }; Game::XAsset asset = { *reinterpret_cast<Game::XAssetType*>(data), header };
Logger::Print("%s\n", Game::DB_GetXAssetName(&asset)); Logger::Print("{}\n", Game::DB_GetXAssetName(&asset));
}, &type, false); }, &type, false);
} }
}); });
@ -1496,7 +1498,8 @@ namespace Components
{ {
Game::DB_EnumXAssets(Game::ASSET_TYPE_MATERIAL, [](Game::XAssetHeader header, void*) Game::DB_EnumXAssets(Game::ASSET_TYPE_MATERIAL, [](Game::XAssetHeader header, void*)
{ {
Logger::Print("%s: %X %X %X\n", header.material->info.name, header.material->info.sortKey & 0xFF, header.material->info.gameFlags & 0xFF, header.material->stateFlags & 0xFF); Logger::Print("{}: {:#X} {:#X} {:#X}\n",
header.material->info.name, header.material->info.sortKey & 0xFF, header.material->info.gameFlags & 0xFF, header.material->stateFlags & 0xFF);
}, nullptr, false); }, nullptr, false);
}); });
@ -1521,7 +1524,7 @@ namespace Components
} }
Logger::Print("------------------- BEGIN IWI DUMP -------------------\n"); Logger::Print("------------------- BEGIN IWI DUMP -------------------\n");
Logger::Print("%s\n", json11::Json(images).dump().data()); Logger::Print("{}\n", json11::Json(images).dump());
Logger::Print("------------------- END IWI DUMP -------------------\n"); Logger::Print("------------------- END IWI DUMP -------------------\n");
}); });

View File

@ -139,7 +139,7 @@ namespace Components
static std::string FindMaterialByTechnique(const std::string& name); static std::string FindMaterialByTechnique(const std::string& name);
static int __stdcall EntryPoint(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int /*nShowCmd*/); static int __stdcall EntryPoint(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int /*nShowCmd*/);
static void HandleError(int level, const char* format, ...); static void HandleError(Game::errorParm_t code, const char* fmt, ...);
static void SoftErrorAssetOverflow(); static void SoftErrorAssetOverflow();
static void AssumeMainThreadRole(); static void AssumeMainThreadRole();

View File

@ -246,7 +246,7 @@ namespace Components
// Check if that special flag is set // Check if that special flag is set
if (!(surface332.flag & 0x20)) if (!(surface332.flag & 0x20))
{ {
Logger::Error("We're not able to handle XSurface buffer allocation yet!"); Logger::Error(Game::ERR_FATAL, "We're not able to handle XSurface buffer allocation yet!");
} }
// Copy the correct data back to our surface // Copy the correct data back to our surface
@ -3521,7 +3521,7 @@ namespace Components
Command::Add("decryptImages", [](Command::Params*) Command::Add("decryptImages", [](Command::Params*)
{ {
auto images = Game::Sys_ListFilesWrapper("iw4x/images", "iwi"); auto images = Game::Sys_ListFilesWrapper("iw4x/images", "iwi");
Logger::Print("decrypting %u images...\n", images.size()); Logger::Print("decrypting {} images...\n", images.size());
for (auto& image : images) for (auto& image : images)
{ {
@ -3549,12 +3549,12 @@ namespace Components
} }
} }
Logger::Print("decrypted %u images!\n", images.size()); Logger::Print("decrypted {} images!\n", images.size());
}); });
Command::Add("decryptSounds", [](Command::Params*) Command::Add("decryptSounds", [](Command::Params*)
{ {
auto sounds = Game::Sys_ListFilesWrapper("iw4x/sound", "iwi"); auto sounds = Game::Sys_ListFilesWrapper("iw4x/sound", "iwi");
Logger::Print("decrypting %u sounds...\n", sounds.size()); Logger::Print("decrypting {} sounds...\n", sounds.size());
for (auto& sound : sounds) for (auto& sound : sounds)
{ {
@ -3580,7 +3580,7 @@ namespace Components
} }
} }
Logger::Print("decrypted %u sounds!\n", sounds.size()); Logger::Print("decrypted {} sounds!\n", sounds.size());
}); });
// patch max filecount Sys_ListFiles can return // patch max filecount Sys_ListFiles can return

View File

@ -60,6 +60,7 @@ namespace Game
CL_HandleRelayPacket_t CL_HandleRelayPacket = CL_HandleRelayPacket_t(0x5A8C70); CL_HandleRelayPacket_t CL_HandleRelayPacket = CL_HandleRelayPacket_t(0x5A8C70);
CL_ResetViewport_t CL_ResetViewport = CL_ResetViewport_t(0x4A8830); CL_ResetViewport_t CL_ResetViewport = CL_ResetViewport_t(0x4A8830);
CL_SelectStringTableEntryInDvar_f_t CL_SelectStringTableEntryInDvar_f = CL_SelectStringTableEntryInDvar_f_t(0x4A4560); CL_SelectStringTableEntryInDvar_f_t CL_SelectStringTableEntryInDvar_f = CL_SelectStringTableEntryInDvar_f_t(0x4A4560);
CL_ConsoleFixPosition_t CL_ConsoleFixPosition = CL_ConsoleFixPosition_t(0x44A430);
Cmd_AddCommand_t Cmd_AddCommand = Cmd_AddCommand_t(0x470090); Cmd_AddCommand_t Cmd_AddCommand = Cmd_AddCommand_t(0x470090);
Cmd_AddServerCommand_t Cmd_AddServerCommand = Cmd_AddServerCommand_t(0x4DCE00); Cmd_AddServerCommand_t Cmd_AddServerCommand = Cmd_AddServerCommand_t(0x4DCE00);
@ -69,6 +70,7 @@ namespace Game
Com_Error_t Com_Error = Com_Error_t(0x4B22D0); Com_Error_t Com_Error = Com_Error_t(0x4B22D0);
Com_Printf_t Com_Printf = Com_Printf_t(0x402500); Com_Printf_t Com_Printf = Com_Printf_t(0x402500);
Com_PrintError_t Com_PrintError = Com_PrintError_t(0x4F8C70); Com_PrintError_t Com_PrintError = Com_PrintError_t(0x4F8C70);
Com_PrintWarning_t Com_PrintWarning = Com_PrintWarning_t(0x4E0200);
Com_PrintMessage_t Com_PrintMessage = Com_PrintMessage_t(0x4AA830); Com_PrintMessage_t Com_PrintMessage = Com_PrintMessage_t(0x4AA830);
Com_EndParseSession_t Com_EndParseSession = Com_EndParseSession_t(0x4B80B0); Com_EndParseSession_t Com_EndParseSession = Com_EndParseSession_t(0x4B80B0);
Com_BeginParseSession_t Com_BeginParseSession = Com_BeginParseSession_t(0x4AAB80); Com_BeginParseSession_t Com_BeginParseSession = Com_BeginParseSession_t(0x4AAB80);
@ -77,7 +79,6 @@ namespace Game
Com_MatchToken_t Com_MatchToken = Com_MatchToken_t(0x447130); Com_MatchToken_t Com_MatchToken = Com_MatchToken_t(0x447130);
Com_SetSlowMotion_t Com_SetSlowMotion = Com_SetSlowMotion_t(0x446E20); Com_SetSlowMotion_t Com_SetSlowMotion = Com_SetSlowMotion_t(0x446E20);
Com_Quitf_t Com_Quit_f = Com_Quitf_t(0x4D4000); Com_Quitf_t Com_Quit_f = Com_Quitf_t(0x4D4000);
Com_PrintWarning_t Com_PrintWarning = Com_PrintWarning_t(0x4E0200);
Con_DrawMiniConsole_t Con_DrawMiniConsole = Con_DrawMiniConsole_t(0x464F30); Con_DrawMiniConsole_t Con_DrawMiniConsole = Con_DrawMiniConsole_t(0x464F30);
Con_DrawSolidConsole_t Con_DrawSolidConsole = Con_DrawSolidConsole_t(0x5A5040); Con_DrawSolidConsole_t Con_DrawSolidConsole = Con_DrawSolidConsole_t(0x5A5040);
@ -581,6 +582,12 @@ namespace Game
unsigned long* _tls_index = reinterpret_cast<unsigned long*>(0x66D94A8); unsigned long* _tls_index = reinterpret_cast<unsigned long*>(0x66D94A8);
int* cls_uiStarted = reinterpret_cast<int*>(0xA7FFA0);
int* com_fixedConsolePosition = reinterpret_cast<int*>(0x1AD8EC8);
int* com_errorPrintsCount = reinterpret_cast<int*>(0x1AD7910);
void Sys_LockRead(FastCriticalSection* critSect) void Sys_LockRead(FastCriticalSection* critSect)
{ {
InterlockedIncrement(&critSect->readCount); InterlockedIncrement(&critSect->readCount);
@ -868,22 +875,20 @@ namespace Game
{ {
return reinterpret_cast<char*>(0x6466628); return reinterpret_cast<char*>(0x6466628);
} }
else if (Game::Sys_IsRenderThread()) if (Game::Sys_IsRenderThread())
{ {
return reinterpret_cast<char*>(0x646AC34); return reinterpret_cast<char*>(0x646AC34);
} }
else if (Game::Sys_IsServerThread()) if (Game::Sys_IsServerThread())
{ {
return reinterpret_cast<char*>(0x646F240); return reinterpret_cast<char*>(0x646F240);
} }
else if(Game::Sys_IsDatabaseThread()) if (Game::Sys_IsDatabaseThread())
{ {
return reinterpret_cast<char*>(0x647384C); return reinterpret_cast<char*>(0x647384C);
} }
else
{ return nullptr;
return nullptr;
}
} }
void Com_SetParseNegativeNumbers(int parse) void Com_SetParseNegativeNumbers(int parse)

View File

@ -121,6 +121,9 @@ namespace Game
typedef void(__cdecl * CL_SelectStringTableEntryInDvar_f_t)(); typedef void(__cdecl * CL_SelectStringTableEntryInDvar_f_t)();
extern CL_SelectStringTableEntryInDvar_f_t CL_SelectStringTableEntryInDvar_f; extern CL_SelectStringTableEntryInDvar_f_t CL_SelectStringTableEntryInDvar_f;
typedef void(__cdecl * CL_ConsoleFixPosition_t)();
extern CL_ConsoleFixPosition_t CL_ConsoleFixPosition;
typedef void(__cdecl * Cmd_AddCommand_t)(const char* cmdName, void(*function), cmd_function_t* allocedCmd, bool isKey); typedef void(__cdecl * Cmd_AddCommand_t)(const char* cmdName, void(*function), cmd_function_t* allocedCmd, bool isKey);
extern Cmd_AddCommand_t Cmd_AddCommand; extern Cmd_AddCommand_t Cmd_AddCommand;
@ -136,13 +139,16 @@ namespace Game
typedef void(__cdecl * Com_Error_t)(errorParm_t type, const char* message, ...); typedef void(__cdecl * Com_Error_t)(errorParm_t type, const char* message, ...);
extern Com_Error_t Com_Error; extern Com_Error_t Com_Error;
typedef void(__cdecl * Com_Printf_t)(int channel, const char *fmt, ...); typedef void(__cdecl * Com_Printf_t)(int channel, const char* fmt, ...);
extern Com_Printf_t Com_Printf; extern Com_Printf_t Com_Printf;
typedef void(__cdecl * Com_PrintError_t)(int channel, const char* fmt, ...); typedef void(__cdecl * Com_PrintError_t)(int channel, const char* fmt, ...);
extern Com_PrintError_t Com_PrintError; extern Com_PrintError_t Com_PrintError;
typedef void(__cdecl * Com_PrintMessage_t)(int channel, const char *msg, int error); typedef void(__cdecl * Com_PrintWarning_t)(int channel, const char* fmt, ...);
extern Com_PrintWarning_t Com_PrintWarning;
typedef void(__cdecl * Com_PrintMessage_t)(int channel, const char* msg, int error);
extern Com_PrintMessage_t Com_PrintMessage; extern Com_PrintMessage_t Com_PrintMessage;
typedef void(__cdecl * Com_EndParseSession_t)(); typedef void(__cdecl * Com_EndParseSession_t)();
@ -166,9 +172,6 @@ namespace Game
typedef void(__cdecl * Com_Quitf_t)(); typedef void(__cdecl * Com_Quitf_t)();
extern Com_Quitf_t Com_Quit_f; extern Com_Quitf_t Com_Quit_f;
typedef void(__cdecl * Com_PrintWarning_t)(int, const char*, ...);
extern Com_PrintWarning_t Com_PrintWarning;
typedef char* (__cdecl * Con_DrawMiniConsole_t)(int localClientNum, int xPos, int yPos, float alpha); typedef char* (__cdecl * Con_DrawMiniConsole_t)(int localClientNum, int xPos, int yPos, float alpha);
extern Con_DrawMiniConsole_t Con_DrawMiniConsole; extern Con_DrawMiniConsole_t Con_DrawMiniConsole;
@ -1199,6 +1202,12 @@ namespace Game
extern unsigned long* _tls_index; extern unsigned long* _tls_index;
extern int* cls_uiStarted;
extern int* com_fixedConsolePosition;
extern int* com_errorPrintsCount;
void Sys_LockRead(FastCriticalSection* critSect); void Sys_LockRead(FastCriticalSection* critSect);
void Sys_UnlockRead(FastCriticalSection* critSect); void Sys_UnlockRead(FastCriticalSection* critSect);

View File

@ -19,11 +19,11 @@
#include <Windows.h> #include <Windows.h>
#include <timeapi.h> #include <timeapi.h>
#include <shellapi.h> #include <shellapi.h>
#include <Wininet.h> #include <WinInet.h>
#include <d3d9.h> #include <d3d9.h>
#include <Aclapi.h> #include <AclAPI.h>
#include <Psapi.h> #include <Psapi.h>
#include <tlhelp32.h> #include <TlHelp32.h>
#include <Shlwapi.h> #include <Shlwapi.h>
#pragma warning(push) #pragma warning(push)
@ -46,6 +46,8 @@
#include <optional> #include <optional>
#include <random> #include <random>
#include <chrono> #include <chrono>
#include <format>
#include <source_location>
#pragma warning(pop) #pragma warning(pop)
@ -124,6 +126,7 @@ using namespace std::literals;
#include "Utils/Hooking.hpp" #include "Utils/Hooking.hpp"
#include "Utils/InfoString.hpp" #include "Utils/InfoString.hpp"
#include "Utils/IO.hpp" #include "Utils/IO.hpp"
#include "Utils/Json.hpp"
#include "Utils/Library.hpp" #include "Utils/Library.hpp"
#include "Utils/String.hpp" #include "Utils/String.hpp"
#include "Utils/Thread.hpp" #include "Utils/Thread.hpp"

View File

@ -42,7 +42,6 @@ namespace Steam
int User::InitiateGameConnection(void *pAuthBlob, int cbMaxAuthBlob, SteamID steamIDGameServer, unsigned int unIPServer, unsigned short usPortServer, bool bSecure) int User::InitiateGameConnection(void *pAuthBlob, int cbMaxAuthBlob, SteamID steamIDGameServer, unsigned int unIPServer, unsigned short usPortServer, bool bSecure)
{ {
Components::Logger::Print("%s\n", __FUNCTION__);
return 0; return 0;
} }

25
src/Utils/Json.cpp Normal file
View File

@ -0,0 +1,25 @@
#include <STDInclude.hpp>
namespace Utils::Json
{
std::string TypeToString(json11::Json::Type type)
{
switch (type)
{
case json11::Json::NUL:
return "NUL";
case json11::Json::NUMBER:
return "NUMBER";
case json11::Json::BOOL:
return "BOOL";
case json11::Json::STRING:
return "STRING";
case json11::Json::ARRAY:
return "ARRAY";
case json11::Json::OBJECT:
return "OBJECT";
default:
return "NUL";
}
}
}

6
src/Utils/Json.hpp Normal file
View File

@ -0,0 +1,6 @@
#pragma once
namespace Utils::Json
{
std::string TypeToString(json11::Json::Type type);
}