mirror of
https://github.com/ScrelliCopter/tmx2gba.git
synced 2025-02-21 03:29:25 +11:00
Fixed some stupid leaks & crashes, tool should be pretty stable now.
Also bumped the warning level up to 4 in the VS project settings & fixed some warnings.
This commit is contained in:
@@ -55,7 +55,7 @@ struct SParams
|
|||||||
bool ParseArgs ( int argc, char** argv, SParams* params )
|
bool ParseArgs ( int argc, char** argv, SParams* params )
|
||||||
{
|
{
|
||||||
char cOption;
|
char cOption;
|
||||||
while ( ( cOption = getopt ( argc, argv, "hr:l:c:p:y:i:o:" ) ) > 0 )
|
while ( ( cOption = (char)getopt ( argc, argv, "hr:l:c:p:y:i:o:" ) ) > 0 )
|
||||||
{
|
{
|
||||||
switch ( cOption )
|
switch ( cOption )
|
||||||
{
|
{
|
||||||
@@ -159,7 +159,7 @@ int main ( int argc, char** argv )
|
|||||||
const uint32_t* pPalRead = pLayerPal == nullptr ? nullptr : pLayerPal->GetData ();
|
const uint32_t* pPalRead = pLayerPal == nullptr ? nullptr : pLayerPal->GetData ();
|
||||||
std::vector<uint16_t> vucCharDat;
|
std::vector<uint16_t> vucCharDat;
|
||||||
vucCharDat.reserve ( pLayerGfx->GetWidth () * pLayerGfx->GetHeight () );
|
vucCharDat.reserve ( pLayerGfx->GetWidth () * pLayerGfx->GetHeight () );
|
||||||
for ( size_t i = 0; i < size_t(pLayerGfx->GetWidth () * pLayerGfx->GetHeight () * 2); ++i )
|
for ( size_t i = 0; i < size_t(pLayerGfx->GetWidth () * pLayerGfx->GetHeight ()); ++i )
|
||||||
{
|
{
|
||||||
uint32_t uiRead = (*pRead++);
|
uint32_t uiRead = (*pRead++);
|
||||||
|
|
||||||
@@ -192,7 +192,7 @@ int main ( int argc, char** argv )
|
|||||||
std::cerr << "Failed to create output file.";
|
std::cerr << "Failed to create output file.";
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
fout.write ( (const char*)vucCharDat.data (), vucCharDat.size () );
|
fout.write ( (const char*)vucCharDat.data (), vucCharDat.size () * sizeof(uint16_t) );
|
||||||
fout.close ();
|
fout.close ();
|
||||||
|
|
||||||
// Convert collision map & save it out.
|
// Convert collision map & save it out.
|
||||||
@@ -202,7 +202,7 @@ int main ( int argc, char** argv )
|
|||||||
vucCollisionDat.reserve ( pLayerCls->GetWidth () * pLayerCls->GetHeight () );
|
vucCollisionDat.reserve ( pLayerCls->GetWidth () * pLayerCls->GetHeight () );
|
||||||
|
|
||||||
const uint32_t* pRead = pLayerCls->GetData ();
|
const uint32_t* pRead = pLayerCls->GetData ();
|
||||||
for ( size_t i = 0; i < pLayerCls->GetWidth () * pLayerCls->GetHeight (); ++i )
|
for ( int i = 0; i < pLayerCls->GetWidth () * pLayerCls->GetHeight (); ++i )
|
||||||
{
|
{
|
||||||
uint8_t ucTile = (uint8_t)tmx.LidFromGid ( (*pRead++) & ~FLIP_MASK );
|
uint8_t ucTile = (uint8_t)tmx.LidFromGid ( (*pRead++) & ~FLIP_MASK );
|
||||||
vucCollisionDat.push_back ( ucTile );
|
vucCollisionDat.push_back ( ucTile );
|
||||||
@@ -224,7 +224,7 @@ int main ( int argc, char** argv )
|
|||||||
fout.open ( strPath, std::ios::binary );
|
fout.open ( strPath, std::ios::binary );
|
||||||
if ( fout.is_open () )
|
if ( fout.is_open () )
|
||||||
{
|
{
|
||||||
fout.write ( (const char*)vucCollisionDat.data (), vucCollisionDat.size () );
|
fout.write ( (const char*)vucCollisionDat.data (), vucCollisionDat.size () * sizeof(uint8_t) );
|
||||||
fout.close ();
|
fout.close ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -144,6 +144,7 @@ void CTmxReader::ReadLayer ( rapidxml::xml_node<>* a_xNode )
|
|||||||
pTileDat = new uint32_t[iWidth * iHeight];
|
pTileDat = new uint32_t[iWidth * iHeight];
|
||||||
if ( !DecodeMap ( pTileDat, iWidth * iHeight * sizeof(uint32_t), std::string ( xData->value () ) ) )
|
if ( !DecodeMap ( pTileDat, iWidth * iHeight * sizeof(uint32_t), std::string ( xData->value () ) ) )
|
||||||
{
|
{
|
||||||
|
delete[] pTileDat;
|
||||||
pTileDat = nullptr;
|
pTileDat = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
<PropertyGroup />
|
<PropertyGroup />
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level4</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<AdditionalIncludeDirectories>inc\</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>inc\</AdditionalIncludeDirectories>
|
||||||
@@ -52,7 +52,7 @@
|
|||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level4</WarningLevel>
|
||||||
<Optimization>MaxSpeed</Optimization>
|
<Optimization>MaxSpeed</Optimization>
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
|||||||
Reference in New Issue
Block a user