maint: cleanup some code
This commit is contained in:
parent
af776b4bc8
commit
9c7d22356f
20
appveyor.yml
20
appveyor.yml
@ -1,20 +0,0 @@
|
|||||||
version: 1.0.{build}
|
|
||||||
skip_tags: true
|
|
||||||
image: Visual Studio 2019
|
|
||||||
configuration: release
|
|
||||||
before_build:
|
|
||||||
- git submodule update --init --recursive
|
|
||||||
- ps: tools\premake5.exe vs2019 --set-version="$env:APPVEYOR_BUILD_VERSION"
|
|
||||||
build:
|
|
||||||
project: build/zonetool.sln
|
|
||||||
verbosity: minimal
|
|
||||||
test: off
|
|
||||||
artifacts:
|
|
||||||
- path: build/bin/*.dll
|
|
||||||
- path: build/bin/*.pdb
|
|
||||||
deploy:
|
|
||||||
- provider: GitHub
|
|
||||||
auth_token:
|
|
||||||
secure: IyUTCaq8tOpcOwDfqa2bH2UCEgPNoLpgqZtJOetSchzZcs1rJT8b/oQ/DTq2ecwc
|
|
||||||
on:
|
|
||||||
branch: master
|
|
@ -113,19 +113,19 @@ namespace ZoneTool
|
|||||||
StringTable* StringTable_Parse(std::string name, ZoneMemory* mem)
|
StringTable* StringTable_Parse(std::string name, ZoneMemory* mem)
|
||||||
{
|
{
|
||||||
auto table = std::make_unique<CSV>(name);
|
auto table = std::make_unique<CSV>(name);
|
||||||
auto stringtable = mem->Alloc<StringTable>();
|
auto* stringtable = mem->Alloc<StringTable>();
|
||||||
|
|
||||||
stringtable->name = mem->StrDup(name.c_str());
|
stringtable->name = mem->StrDup(name);
|
||||||
stringtable->rows = table->rows();
|
stringtable->rows = static_cast<int>(table->rows());
|
||||||
stringtable->columns = table->max_columns();
|
stringtable->columns = static_cast<int>(table->max_columns());
|
||||||
stringtable->strings = mem->Alloc<StringTableCell>(stringtable->rows * stringtable->columns);
|
stringtable->strings = mem->Alloc<StringTableCell>(stringtable->rows * stringtable->columns);
|
||||||
|
|
||||||
for (int row = 0; row < table->rows(); row++)
|
for (size_t row = 0; row < table->rows(); row++)
|
||||||
{
|
{
|
||||||
for (int col = 0; col < table->columns(row); col++)
|
for (size_t col = 0; col < table->columns(row); col++)
|
||||||
{
|
{
|
||||||
int entry = (row * stringtable->columns) + col;
|
size_t entry = (row * stringtable->columns) + col;
|
||||||
stringtable->strings[entry].string = mem->StrDup(table->entry(row, col).c_str());
|
stringtable->strings[entry].string = mem->StrDup(table->entry(row, col));
|
||||||
stringtable->strings[entry].hash = StringTable_Hash(stringtable->strings[entry].string);
|
stringtable->strings[entry].hash = StringTable_Hash(stringtable->strings[entry].string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -136,11 +136,11 @@ namespace ZoneTool
|
|||||||
void IStringTable::init(const std::string& name, ZoneMemory* mem)
|
void IStringTable::init(const std::string& name, ZoneMemory* mem)
|
||||||
{
|
{
|
||||||
this->name_ = name;
|
this->name_ = name;
|
||||||
this->asset_ = DB_FindXAssetHeader(this->type(), this->name().data()).stringtable;
|
this->asset_ = DB_FindXAssetHeader(this->type(), this->name().c_str()).stringtable;
|
||||||
|
|
||||||
if (FileSystem::FileExists(name))
|
if (FileSystem::FileExists(name))
|
||||||
{
|
{
|
||||||
ZONETOOL_INFO("Parsing stringtable %s...", name.data());
|
ZONETOOL_INFO("Parsing stringtable %s...", name.c_str());
|
||||||
this->asset_ = StringTable_Parse(name, mem);
|
this->asset_ = StringTable_Parse(name, mem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -422,17 +422,17 @@ namespace ZoneTool
|
|||||||
buf->align(3);
|
buf->align(3);
|
||||||
auto ui = buf->write(data->ui);
|
auto ui = buf->write(data->ui);
|
||||||
|
|
||||||
|
if (ui->dpadIcon)
|
||||||
|
{
|
||||||
|
ui->dpadIcon = reinterpret_cast<Material*>(zone->get_asset_pointer(material, ui->dpadIcon->name));
|
||||||
|
}
|
||||||
|
|
||||||
if (ui->ammoCounterIcon)
|
if (ui->ammoCounterIcon)
|
||||||
{
|
{
|
||||||
ui->ammoCounterIcon = reinterpret_cast<Material*>(zone->get_asset_pointer(
|
ui->ammoCounterIcon = reinterpret_cast<Material*>(zone->get_asset_pointer(
|
||||||
material, ui->ammoCounterIcon->name));
|
material, ui->ammoCounterIcon->name));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ui->dpadIcon)
|
|
||||||
{
|
|
||||||
ui->dpadIcon = reinterpret_cast<Material*>(zone->get_asset_pointer(material, ui->dpadIcon->name));
|
|
||||||
}
|
|
||||||
|
|
||||||
ZoneBuffer::clear_pointer(&dest->ui);
|
ZoneBuffer::clear_pointer(&dest->ui);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,19 +113,19 @@ namespace ZoneTool
|
|||||||
StringTable* StringTable_Parse(std::string name, ZoneMemory* mem)
|
StringTable* StringTable_Parse(std::string name, ZoneMemory* mem)
|
||||||
{
|
{
|
||||||
auto table = std::make_unique<CSV>(name);
|
auto table = std::make_unique<CSV>(name);
|
||||||
auto stringtable = mem->Alloc<StringTable>();
|
auto* stringtable = mem->Alloc<StringTable>();
|
||||||
|
|
||||||
stringtable->name = mem->StrDup(name.c_str());
|
stringtable->name = mem->StrDup(name);
|
||||||
stringtable->rows = table->rows();
|
stringtable->rows = static_cast<int>(table->rows());
|
||||||
stringtable->columns = table->max_columns();
|
stringtable->columns = static_cast<int>(table->max_columns());
|
||||||
stringtable->strings = mem->Alloc<StringTableCell>(stringtable->rows * stringtable->columns);
|
stringtable->strings = mem->Alloc<StringTableCell>(stringtable->rows * stringtable->columns);
|
||||||
|
|
||||||
for (int row = 0; row < table->rows(); row++)
|
for (size_t row = 0; row < table->rows(); row++)
|
||||||
{
|
{
|
||||||
for (int col = 0; col < table->columns(row); col++)
|
for (size_t col = 0; col < table->columns(row); col++)
|
||||||
{
|
{
|
||||||
int entry = (row * stringtable->columns) + col;
|
size_t entry = (row * stringtable->columns) + col;
|
||||||
stringtable->strings[entry].string = mem->StrDup(table->entry(row, col).c_str());
|
stringtable->strings[entry].string = mem->StrDup(table->entry(row, col));
|
||||||
stringtable->strings[entry].hash = StringTable_Hash(stringtable->strings[entry].string);
|
stringtable->strings[entry].hash = StringTable_Hash(stringtable->strings[entry].string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -136,11 +136,11 @@ namespace ZoneTool
|
|||||||
void IStringTable::init(const std::string& name, ZoneMemory* mem)
|
void IStringTable::init(const std::string& name, ZoneMemory* mem)
|
||||||
{
|
{
|
||||||
this->name_ = name;
|
this->name_ = name;
|
||||||
this->asset_ = DB_FindXAssetHeader(this->type(), this->name().data(), 1).stringtable;
|
this->asset_ = DB_FindXAssetHeader(this->type(), this->name().c_str(), 1).stringtable;
|
||||||
|
|
||||||
if (FileSystem::FileExists(name))
|
if (FileSystem::FileExists(name))
|
||||||
{
|
{
|
||||||
ZONETOOL_INFO("Parsing stringtable %s...", name.data());
|
ZONETOOL_INFO("Parsing stringtable %s...", name.c_str());
|
||||||
this->asset_ = StringTable_Parse(name, mem);
|
this->asset_ = StringTable_Parse(name, mem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,8 +66,10 @@ namespace ZoneTool
|
|||||||
|
|
||||||
// get string length
|
// get string length
|
||||||
auto len = strlen(name) + 1;
|
auto len = strlen(name) + 1;
|
||||||
auto pointer = this->ManualAlloc<char>(len);
|
auto* pointer = this->ManualAlloc<char>(len);
|
||||||
|
assert(pointer != nullptr);
|
||||||
memcpy(pointer, name, len);
|
memcpy(pointer, name, len);
|
||||||
|
pointer[len - 1] = '\0';
|
||||||
|
|
||||||
// return pointer
|
// return pointer
|
||||||
return pointer;
|
return pointer;
|
||||||
@ -76,7 +78,7 @@ namespace ZoneTool
|
|||||||
char* StrDup(const std::string& name)
|
char* StrDup(const std::string& name)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::recursive_mutex> g(this->mutex_);
|
std::lock_guard<std::recursive_mutex> g(this->mutex_);
|
||||||
return this->StrDup(name.data());
|
return this->StrDup(name.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -99,7 +101,8 @@ namespace ZoneTool
|
|||||||
std::lock_guard<std::recursive_mutex> g(this->mutex_);
|
std::lock_guard<std::recursive_mutex> g(this->mutex_);
|
||||||
|
|
||||||
// alloc pointer and zero it out
|
// alloc pointer and zero it out
|
||||||
auto pointer = reinterpret_cast<char*>(memory_pool_) + mem_pos_;
|
auto* pointer = reinterpret_cast<char*>(memory_pool_) + mem_pos_;
|
||||||
|
assert(pointer != nullptr);
|
||||||
memset(pointer, 0, size * count);
|
memset(pointer, 0, size * count);
|
||||||
mem_pos_ += size * count;
|
mem_pos_ += size * count;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user