Remaster tilesets now load correctly.

This commit is contained in:
Justin Marshall
2020-06-20 16:59:56 -07:00
parent acc1af0c05
commit ae4763251c
12 changed files with 5428 additions and 31 deletions
+4 -2
View File
@@ -624,6 +624,7 @@ set(src_redalert
./RedAlert/_WSPROTO.H
./REDALERT/MapScript.cpp
./REDALERT/TXTPRNT.cpp
./REDALERT/TILESETXML.cpp
)
set(src_external
@@ -710,7 +711,8 @@ set(src_external
./external/lua/lvm.h
./external/lua/lzio.c
./external/lua/lzio.h
./external/xml/tinyxml2.cpp
./external/xml/tinyxml2.h
)
@@ -719,5 +721,5 @@ add_compile_options(/permissive+ /Zc:forScope- /Zp1)
add_executable(RedAlert ${src_io} ${src_win32lib} ${src_redalert} ${src_external})
set_target_properties(RedAlert PROPERTIES OUTPUT_NAME "RedAlert" LINK_FLAGS "/PDB:\"RedAlert.pdb\" /SUBSYSTEM:WINDOWS" RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/../" )
target_include_directories(RedAlert PRIVATE ./external/devil/;./external/;./redalert/win32lib;./external/lua/;./external/imgui;./external/dxsdk/Include;./external/ffmpeg-win32/include;./external/sdl2/include;./win32lib;./external/openal/include)
target_include_directories(RedAlert PRIVATE ./external/xml/;./external/devil/;./external/;./redalert/win32lib;./external/lua/;./external/imgui;./external/dxsdk/Include;./external/ffmpeg-win32/include;./external/sdl2/include;./win32lib;./external/openal/include)
target_link_libraries(RedAlert "opengl32.lib" "winmm.lib" "Ws2_32.lib" "${CMAKE_SOURCE_DIR}/external/devil/ilu.lib" "${CMAKE_SOURCE_DIR}/external/devil/DevIL.lib" "${CMAKE_SOURCE_DIR}/external/sdl2/lib/x86/SDL2.lib" "${CMAKE_SOURCE_DIR}/external/openal/out/build/x86-Release/OpenAL32.lib")
+1 -1
View File
@@ -3138,7 +3138,7 @@ void TemplateTypeClass::Init(TheaterType theater)
((unsigned char &)tplate.Height) = Get_IconSet_MapHeight(ptr);
// Try and load HD assets first.
Image_t *hdImage = Load_StampHD(Theaters[theater].Name, fullname, tplate.ImageData);
Image_t *hdImage = Load_StampHD(theater, fullname, tplate.ImageData);
if (hdImage)
{
Get_Stamp_Size(tplate.ImageData, hdImage->renderwidth, hdImage->renderheight);
+3
View File
@@ -1179,6 +1179,9 @@ __forceinline void COM_SetExtension(char* path, int maxSize, const char* extensi
sprintf(path, "%s%s", oldPath, extension);
}
void Tileset_LoadRules(void);
const char* Tileset_FindHDTexture(int theaterType, const char* shapeFileName, int shapeNum);
extern bool g_inMainMenu;
extern KeyNumType g_globalKeyNumType;
extern int g_globalKeyFlags;
+3
View File
@@ -387,6 +387,9 @@ int PASCAL WinMain ( HINSTANCE instance , HINSTANCE , char * command_line , int
#endif
// Load all of the XML files.
Tileset_LoadRules();
if (Parse_Command_Line(argc, argv)) {
#if(TEN)
+1 -1
View File
@@ -691,7 +691,7 @@ void TerrainTypeClass::Init(TheaterType theater)
((void const *&)terrain.ImageData) = MFCD::Retrieve(fullname);
// Try and load HD assets first.
Image_t* hdImage = Load_StampHD(Theaters[theater].Name, fullname, terrain.ImageData);
Image_t* hdImage = Load_StampHD(theater, fullname, terrain.ImageData);
if (hdImage)
{
Get_Stamp_Size(terrain.ImageData, hdImage->renderwidth, hdImage->renderheight);
+15 -24
View File
@@ -190,7 +190,7 @@ void __cdecl Buffer_Draw_Stamp2(GraphicViewPortClass& viewport, IconControlType*
}
}
Image_t* Load_StampHD(const char* theaterName, const char* iconName, const void* icondata) {
Image_t* Load_StampHD(int theater, const char* iconName, const void* icondata) {
char filename[2048];
Image_t* image = NULL;
@@ -205,33 +205,24 @@ Image_t* Load_StampHD(const char* theaterName, const char* iconName, const void*
}
// This is because were trying to avoid parsing the XML's and the filenames aren't consistant.
char* baseFileNameTemplate = "DATA/ART/TEXTURES/SRGB/RED_ALERT/TERRAIN/%s/%s/%s-%04d.DDS";
char* fileNameTemplate = baseFileNameTemplate;
const char* theaterName = Theaters[theater].Name;
for (int i = 0; i < IconCount; i++)
{
sprintf(filename, fileNameTemplate, theaterName, iconName, iconName, i);
char filename[512];
char fixedIconName[512];
strcpy(fixedIconName, iconName);
COM_SetExtension(fixedIconName, strlen(fixedIconName), "");
const char* tileEntryName = Tileset_FindHDTexture(theater, fixedIconName, i);
sprintf(filename, "DATA/ART/TEXTURES/SRGB/RED_ALERT/TERRAIN/%s/%s", Theaters[theater].Name, tileEntryName);
COM_SetExtension(filename, sizeof(filename), ".dds");
if (image == NULL) {
image = Image_LoadImage(filename);
if (image == NULL) {
fileNameTemplate = "DATA/ART/TEXTURES/SRGB/RED_ALERT/TERRAIN/%s/%s/%s-%04d-0000.DDS";
sprintf(filename, fileNameTemplate, theaterName, iconName, iconName, i);
image = Image_LoadImage(filename);
if (image == NULL) {
fileNameTemplate = "DATA/ART/TEXTURES/SRGB/RED_ALERT/TERRAIN/%s/%s/%s-%04d-00.DDS";
sprintf(filename, fileNameTemplate, theaterName, iconName, iconName, i);
image = Image_LoadImage(filename);
if (image == NULL) {
fileNameTemplate = baseFileNameTemplate; // Restore back to the original template.
continue;
}
}
}
image = Image_LoadImage(filename);
//if (i != 0) {
// image->image[0][i] = image->image[0][0];
// image->image[0][0] = 0;
//}
if (image != NULL && i != 0) {
image->image[0][i] = image->image[0][0];
image->image[0][0] = 0;
}
}
else {
if (!Image_Add32BitImage(filename, image, -1, i)) {
+72
View File
@@ -0,0 +1,72 @@
// TILESETXML.CPP
//
#include "FUNCTION.H"
#include "tinyxml2.h"
#include <string>
#include <vector>
int64_t generateHashValue(const char* fname, const int size);
struct TilesetTileRule_t {
std::string name;
int64_t hash;
int shape;
std::vector<std::string> frames;
};
struct TilesetXMLInfo_t {
std::vector< TilesetTileRule_t> tiles;
};
TilesetXMLInfo_t theaterXMLRules[3];
const char* Tileset_FindHDTexture(int theaterType, const char* shapeFileName, int shapeNum) {
int64_t hash = generateHashValue(shapeFileName, strlen(shapeFileName));
for (int i = 0; i < theaterXMLRules[theaterType].tiles.size(); i++) {
if (theaterXMLRules[theaterType].tiles[i].hash == hash && theaterXMLRules[theaterType].tiles[i].shape == shapeNum) {
return theaterXMLRules[theaterType].tiles[i].frames[0].c_str();
}
}
return NULL;
}
void Tileset_ParseTile(tinyxml2::XMLNode* tile, TilesetTileRule_t& tileRule) {
tinyxml2::XMLNode* KeyNode = tile->FirstChildElement("Key");
tinyxml2::XMLNode* NameNode = KeyNode->FirstChildElement("Name");
tinyxml2::XMLNode* ShapeNode = KeyNode->FirstChildElement("Shape");
tinyxml2::XMLNode* ValueNode = tile->FirstChildElement("Value");
tinyxml2::XMLNode* FramesNode = ValueNode->FirstChildElement("Frames");
tinyxml2::XMLNode* FrameNode = FramesNode->FirstChildElement("Frame");
tileRule.name = NameNode->FirstChild()->ToText()->Value();
tileRule.hash = generateHashValue(tileRule.name.c_str(), tileRule.name.size());
tileRule.shape = atoi(ShapeNode->FirstChild()->ToText()->Value());
tileRule.frames.push_back(FrameNode->FirstChild()->ToText()->Value());
}
void Tileset_LoadRuleXML(const char* path, TilesetXMLInfo_t& info) {
tinyxml2::XMLDocument doc;
doc.LoadFile(path);
tinyxml2::XMLElement* root = doc.FirstChildElement();
tinyxml2::XMLNode* tilesetTypeClassNode = root->FirstChild();
tinyxml2::XMLNode* tilesParent = tilesetTypeClassNode->FirstChildElement("Tiles");
tinyxml2::XMLNode* tile = tilesParent->FirstChildElement("Tile");
while (tile != NULL) {
TilesetTileRule_t tileRule;
Tileset_ParseTile(tile, tileRule);
info.tiles.push_back(tileRule);
tile = tile->NextSiblingElement("Tile");
}
}
void Tileset_LoadRules(void) {
for (int i = 0; i < 3; i++) {
char tmp[512];
sprintf(tmp, "data/xml/tilesets/ra_terrain_%s.xml", Theaters[i].Name);
Tileset_LoadRuleXML(tmp, theaterXMLRules[i]);
}
}
-1
View File
@@ -42,7 +42,6 @@ class MapEditClass;
class HouseClass;
class WeaponTypeClass;
/***************************************************************************
** This is the abstract type class. It holds information common to all
** objects that might exist. This contains the name of the object type.
+1 -1
View File
@@ -65,7 +65,7 @@ struct Image_t;
Image_t* Load_Stamp(const char* name, const void* icondata);
void Get_Stamp_Size(const void* icondata, int &width, int &height);
Image_t* Load_StampHD(const char* theaterName, const char* iconName, const void *icondata);
Image_t* Load_StampHD(int theater, const char* iconName, const void *icondata);
extern GraphicViewPortClass *LogicPage;
extern BOOL AllowHardwareBlitFills;
+1 -1
View File
@@ -102,7 +102,7 @@ unsigned char* Draw_Dropsample(const unsigned char* in, int inwidth, int inheigh
return a hash value for the filename
================
*/
static int64_t generateHashValue(const char* fname, const int size) {
int64_t generateHashValue(const char* fname, const int size) {
uint32_t hash = 0x811c9dc5;
uint32_t prime = 0x1000193;
+2951
View File
File diff suppressed because it is too large Load Diff
+2376
View File
File diff suppressed because it is too large Load Diff