Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions components/asset_util/cmds/cmd_ents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ struct EntityTable

int ParseEnts(const char* ents_str, EntityTable* ents_table)
{
std::vector<const char*> stack;

const char* str_start = NULL;
const char* ent_start = NULL;
int ent_level = 0; // Its like ESP but for ents!
Expand Down Expand Up @@ -66,7 +64,7 @@ int ParseEnts(const char* ents_str, EntityTable* ents_table)
}
else if (strType == ParseEnts_StrType::VALUE)
{
kv.value = str;
kv.value = std::move(str);
ent.push_back(kv);
kv.key.clear();
kv.value.clear();
Expand Down Expand Up @@ -193,10 +191,10 @@ int AddBrushes(EntityTable* ents_table)
continue;

KeyValuePair kv;
kv.key = "";
kv.key.clear();
std::string value = FormatBrush(offset, 64);

kv.value = value;
kv.value = std::move(value);

ent.push_back(kv);
}
Expand Down Expand Up @@ -316,6 +314,7 @@ int Ents_ExtractFromFastfile(const char* filepath, const char* outpath = NULL) {
//Any fastfiles that claim they decompress to a file >= 1GB
//are either corrupt or do not belong to the vanilla game
Con_Error("ERROR: Skipping %s\n", filepath);
delete[] cBuf;
return 1;
}

Expand Down
19 changes: 15 additions & 4 deletions components/asset_util/cmds/cmd_search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ enum class FileType
{
IWD,
FF,

ERR,
};

Expand All @@ -24,11 +23,23 @@ struct FileEntry
std::string name;
std::string path;

FileEntry(FileType t, std::string n, std::string p)
{
type = std::move(t);
name = std::move(n);
path = std::move(p);
}

FileEntry(void)
{
Clear();
}

void Clear(void)
{
type = FileType::ERR;
path = "";
name = "";
name.clear();
path.clear();
}
};

Expand All @@ -52,7 +63,7 @@ class CachedFile
public:
std::string test;

CachedFile(void) : data(NULL), size(0)
CachedFile(void) : entry(), data(NULL), size(0)
{
}

Expand Down
6 changes: 3 additions & 3 deletions components/asset_util/cmds/ripper/snd_ripper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ int Rip_SoundBank_Soundalias_Callback_f(ForeignPointer<SndBank>& bank, ForeignPo

std::string language = "<error>";

auto _offset = name.find_last_of(".");
auto _offset = name.find_last_of('.');
if (_offset != std::string::npos && _offset + 1 < name.size())
language = std::string(name, _offset + 1);
else
Expand Down Expand Up @@ -510,7 +510,7 @@ int Rip_SoundBank_Callback_f(ForeignPointer<XAsset>& asset, ForeignPointer<XZone
}


int Rip_Snapshot_Callback_f(std::string name, std::vector<ForeignPointer<snd_snapshot>>& snapshots)
int Rip_Snapshot_Callback_f(const std::string& name, std::vector<ForeignPointer<snd_snapshot>>& snapshots)
{
Con_Print("Exporting snapshot %s.snapshot.csv...\n", name.c_str());

Expand Down Expand Up @@ -564,7 +564,7 @@ int Rip_Snapshot_Callback_f(std::string name, std::vector<ForeignPointer<snd_sna
return 0;
}

int Rip_Radverb_Callback_f(std::string name, std::vector<ForeignPointer<snd_radverb>>& radverbs)
int Rip_Radverb_Callback_f(const std::string& name, std::vector<ForeignPointer<snd_radverb>>& radverbs)
{
Con_Print("Exporting snapshot %s.radverb.csv...\n", name.c_str());

Expand Down
4 changes: 2 additions & 2 deletions components/asset_util/cmds/ripper/snd_ripper.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ int Rip_SoundBank_GatherSnapshots_Callback_f(ForeignPointer<XAsset>& asset, Fore
int Rip_SoundBank_GatherRadverbs_Callback_f(ForeignPointer<XAsset>& asset, ForeignPointer<XZoneName>& zoneName, void* data);

int Rip_SoundBank_Callback_f(ForeignPointer<XAsset>& asset, ForeignPointer<XZoneName>& zoneName, void* data);
int Rip_Snapshot_Callback_f(std::string name, std::vector<ForeignPointer<snd_snapshot>>& snapshots);
int Rip_Radverb_Callback_f(std::string name, std::vector<ForeignPointer<snd_radverb>>& radverbs);
int Rip_Snapshot_Callback_f(const std::string& name, std::vector<ForeignPointer<snd_snapshot>>& snapshots);
int Rip_Radverb_Callback_f(const std::string& name, std::vector<ForeignPointer<snd_radverb>>& radverbs);
11 changes: 4 additions & 7 deletions components/asset_util/cmds/search/handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,17 +211,14 @@ class Handler
_SlotHandleData_f HandlerCallback=Handler::_SlotHandleData_DefaultCallback,
_SlotInit_f InitCallback = Handler::_SlotInit_DefaultCallback,
_SlotPostInit_f PostInitCallback = Handler::_SlotPostInit_DefaultCallback)
: input_data(source_data), input_index(0),
_SlotInit_Callback(InitCallback),
_SlotPostInit_Callback(PostInitCallback),
_SlotHandleData_Callback(HandlerCallback)
{
numSlots = _slotCount;
slots = new _SLOT_T *[numSlots];
memset(slots, 0, sizeof(_SLOT_T *) * numSlots);

input_data = source_data;
input_index = 0;

_SlotInit_Callback = InitCallback;
_SlotPostInit_Callback = PostInitCallback;
_SlotHandleData_Callback = HandlerCallback;
}

~Handler()
Expand Down
1 change: 1 addition & 0 deletions components/asset_util/common/ff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ int FF_FFExtract(const char* filepath, const char* filename)
//Any fastfiles that claim they decompress to a file >= 1GB
//are either corrupt or do not belong to the vanilla game
Con_Error("ERROR: Skipping %s\n", filename);
delete[] cBuf;
return 1;
}

Expand Down
2 changes: 1 addition & 1 deletion components/asset_util/common/fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ int FS_CreatePath(const char* _targetPath)
strncpy(buf + strlen(buf), targetPath, i);

char* qpath = buf;
if (strlen(qpath) == 0)
if (qpath[0] == '\0')
continue;

FS_SanitizePath(qpath);
Expand Down
11 changes: 7 additions & 4 deletions components/asset_util/common/iwd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ int __cdecl IWD_IWDHandler(const char* iwdPath, const char* iwdName)
}
else if (g_extractImages.ValueBool())
{
sprintf_s(sub, "IMAGE");
char subdst[MAX_PATH];
sprintf_s(subdst, "IMAGE");

if (g_extractSounds.ValueBool())
{
sprintf_s(sub, "%s and %s", sub, "AUDIO");
sprintf_s(sub, "%s and %s", subdst, "AUDIO");
}
}
else
Expand Down Expand Up @@ -92,6 +93,8 @@ int __cdecl IWD_IWDExtract(const char* iwdPath, const char* iwdName)
}

int extractedCount = 0;
size_t lenDirImage = strlen(IWD_DIR_IMAGE);
size_t lenDirSound = strlen(IWD_DIR_SOUND);
for (int f = 0; f < (int)mz_zip_reader_get_num_files(&iwd); f++)
{
mz_zip_archive_file_stat file_stat;
Expand All @@ -102,12 +105,12 @@ int __cdecl IWD_IWDExtract(const char* iwdPath, const char* iwdName)
return -1;
}

if (g_extractImages.ValueBool() && _strnicmp(IWD_DIR_IMAGE, file_stat.m_filename, strlen(IWD_DIR_IMAGE)) == 0)
if (g_extractImages.ValueBool() && _strnicmp(IWD_DIR_IMAGE, file_stat.m_filename, lenDirImage) == 0)
{
IWD_IWDExtractFile(&iwd, file_stat.m_filename);
continue;
}
else if (g_extractSounds.ValueBool() && _strnicmp(IWD_DIR_SOUND, file_stat.m_filename, strlen(IWD_DIR_SOUND)) == 0)
else if (g_extractSounds.ValueBool() && _strnicmp(IWD_DIR_SOUND, file_stat.m_filename, lenDirSound) == 0)
{
IWD_IWDExtractFile(&iwd, file_stat.m_filename);
continue;
Expand Down
6 changes: 3 additions & 3 deletions components/asset_util/gdt/assettype/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ int Character::ExtractFromGSC(const char* qpath)
GSC_Character_ExtractAliasEntry("legDmg4", str.c_str(), &this->legDmg[3], "");

// misc models arent supported right now
this->misc[0].model = "";
this->misc[1].model = "";
this->misc[2].model = "";
this->misc[0].model.clear();
this->misc[1].model.clear();
this->misc[2].model.clear();

/* Unsupported - Can't find any examples of these

Expand Down
2 changes: 1 addition & 1 deletion components/asset_util/gdt/assettype/xmodelalias.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ XModelAlias::XModelAlias()
{
for (int i = 0; i < XMODELALIAS_MODELCOUNT; i++)
{
this->model[i] = "";
this->model[i].clear();
}
}

Expand Down
4 changes: 2 additions & 2 deletions components/asset_util/sys/AppInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ const char* AppInfo_RawDir()

const char* AppInfo_OutDir()
{
if (strlen(fs_outdir.ValueString()) == 0)
if (fs_outdir.ValueString()[0] == '\0')
return AppInfo_RawDir();

if (strstr(fs_outdir.ValueString(), ":") != NULL && strstr(fs_outdir.ValueString(), ":") != fs_outdir.ValueString() + 1)
if (strchr(fs_outdir.ValueString(), ':') != NULL && strchr(fs_outdir.ValueString(), ':') != fs_outdir.ValueString() + 1)
{
Con_Warning("Invalid output directory - falling back to default\n");
fs_outdir.AssignRawString("");
Expand Down
36 changes: 30 additions & 6 deletions components/asset_viewer/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,12 @@ BOOL AssetViewerMod_Init()
//
if (AllocConsole())
{
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
freopen("CONIN$", "r", stdin);
if (freopen("CONOUT$", "w", stdout) == NULL)
return FALSE;
if (freopen("CONOUT$", "w", stderr) == NULL)
return FALSE;
if (freopen("CONIN$", "r", stdin) == NULL)
return FALSE;
}

#if USE_NSIGHT_FIX
Expand Down Expand Up @@ -102,13 +105,34 @@ BOOL AssetViewerMod_Init()
return TRUE;
}

BOOL AssetViewerMod_Destroy()
{
//
// Destroy an external console for AssetViewer
//
if (AllocConsole())
{
fclose(stdout);
fclose(stderr);
fclose(stdin);
}

return TRUE;
}

BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
BOOL initialized = TRUE;
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hModule);
return AssetViewerMod_Init();
initialized = AssetViewerMod_Init();
break;
case DLL_PROCESS_DETACH:
initialized = AssetViewerMod_Destroy();
break;
}

return TRUE;
return initialized;
}
8 changes: 4 additions & 4 deletions components/cod2rad/r_lightmaps.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "stdafx.h"
#include "stdafx.h"

#define LOG_VEC_EQ(A,B) if (A != B) { printf("(%f) %f %f %f == %f %f %f\n", Vec3Variance(&A, &B), A.x, A.y, A.z, B.x, B.y, B.z); }

Expand Down Expand Up @@ -467,13 +467,13 @@ void ImproveLightingApproximation(vec3* lighting, vec3 *highlightDir, vec3* pel_
}
}

*pel_amb = new_pel_amb;
*pel_dir = new_pel_dir;
*pel_amb = std::move(new_pel_amb);
*pel_dir = std::move(new_pel_dir);

initialByteDir[0] = updatedByteDir[0];
initialByteDir[1] = updatedByteDir[1];

*highlightDir = dir;
*highlightDir = std::move(dir);

error = curError;
}
Expand Down
3 changes: 3 additions & 0 deletions components/game_mod/patch_reflections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,15 @@ BOOL LoadBSPReflectionData(const char* bspPath, BYTE* dest, size_t destSize)
if (padded(size) != padded(destSize))
{
printf("ERROR: Fastfile probe count does not match the BSP probe count - please rebuild fastfile\n");
delete[] index;
fclose(h);

return FALSE;
}

fseek(h, offset, SEEK_SET);
fread(dest, 1, size, h);
delete[] index;
fclose(h);

return TRUE;
Expand Down
2 changes: 1 addition & 1 deletion components/installer/bootstrap/exports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ extern "C" {
bool __stdcall LMI_SetInstallPath(const char* path)
{
const std::string binaryPath = FS::JoinPath(path, "BlackOps.exe");
return FS::FileExists(binaryPath.c_str());
return FS::FileExists(binaryPath);
}

int __stdcall LMI_CompareVersions(const char* a, const char* b)
Expand Down
2 changes: 1 addition & 1 deletion components/installer/bootstrap/pe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace pe {
};

const auto _module = FormatName(moduleName);
const auto _symbol = symbolName != nullptr ? FormatName(symbolName) : std::string("");
const auto _symbol = symbolName != nullptr ? FormatName(symbolName) : std::string();

// Iterate over all modules used by the given image
const auto moduleList = get_imported_functions(image);
Expand Down
2 changes: 1 addition & 1 deletion components/installer/bootstrap/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ bool Pipe::Read(std::string& dst) {
//
CloseHandle_s(_hWrite);

dst = "";
dst.clear();
dst.resize(bufLen);

DWORD dwRead = 0;
Expand Down
8 changes: 4 additions & 4 deletions components/radiant_mod/r_draw_shadowablelight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,19 @@ void R_BuildSpotLightInfo(float* source, GfxLight* light, float spotShadowFade)
const float farEdge = g_lightInfo.kvs.far_edge; //0.0f;

vec4 aAbB; // = { 0.0f, 1.0f, 0.0f, 1.0f };
memcpy(&aAbB, &g_lightInfo.kvs.superellipse, sizeof(vec4));
memcpy(&aAbB, &g_lightInfo.kvs.superellipse, sizeof(aAbB));

vec4 attenuation; // = { 1.0f, 0.0f, 0.0f, 0.0f };
memcpy(&attenuation, &g_lightInfo.kvs.attenuation, sizeof(vec3));
memcpy(&attenuation, &g_lightInfo.kvs.attenuation, sizeof(attenuation));

vec4 fallOff;
fallOff.x = cutOn;
fallOff.y = light->radius;
fallOff.z = ((light->radius - cutOn) * nearEdge) + cutOn;
fallOff.w = ((light->radius - cutOn) * farEdge) + cutOn;

memcpy(&g_lightInfo.aAbB, &aAbB, sizeof(vec4));
memcpy(&g_lightInfo.attenuation, &attenuation, sizeof(vec4));
memcpy(&g_lightInfo.aAbB, &aAbB, sizeof(g_lightInfo.aAbB));
memcpy(&g_lightInfo.attenuation, &attenuation, sizeof(g_lightInfo.attenuation));

vec4 angles = { 0.0f, 0.0f, 0.0f, 0.0f };
memcpy(&angles, light->angles, sizeof(float) * 3);
Expand Down
2 changes: 1 addition & 1 deletion components/radiant_mod/r_image_load_obj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ bool Image_LoadFromFileWithReader(GfxImage *image, int (__cdecl * OpenFileRead)(
int picmip = image->picmip.platform[/*useFastFile->current.enabled == 0*/0];
char streamedMipLevels = picmip > 0;

int readSize = fileHeader.fileSizeForPicmip[picmip > 0] - 48;
int readSize = fileHeader.fileSizeForPicmip[streamedMipLevels] - 48;
char *imageData = (char *)Z_Malloc(readSize);

if (FS_Read(imageData, readSize, fileHandle) == readSize)
Expand Down
2 changes: 1 addition & 1 deletion components/shared/detours/AsmGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ BYTE *AsmGen::GetStream(bool Free)
BYTE *data = (BYTE *)malloc(m_Stream.size() * sizeof(BYTE));

for (size_t i = 0; i < m_Stream.size(); i++)
data[i] = m_Stream.at(i);
data[i] = m_Stream[i];

m_StreamData = (Free) ? data : nullptr;

Expand Down
Loading