mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
- Added extra msg file reading based on names given in ddraw.ini.
- Added fetching strings from extra msg files.
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
#include "sound.h"
|
||||
#include "SuperSave.h"
|
||||
#include "version.h"
|
||||
#include "Message.h"
|
||||
|
||||
#define MAX_GLOBAL_SIZE (MaxGlobalVars*12 + 4)
|
||||
|
||||
@@ -276,6 +277,45 @@ end:
|
||||
retn;
|
||||
}
|
||||
}
|
||||
|
||||
void ReadExtraGameMsgFiles()
|
||||
{
|
||||
int read;
|
||||
std::string names;
|
||||
|
||||
names.resize(256);
|
||||
|
||||
while ((read = GetPrivateProfileStringA("Misc", "ExtraGameMsgFileList", "",
|
||||
(LPSTR)names.data(), names.size(), ".\\ddraw.ini")) == names.size() - 1)
|
||||
names.resize(names.size() + 256);
|
||||
|
||||
if (names.empty())
|
||||
return;
|
||||
|
||||
names.resize(names.find_first_of('\0'));
|
||||
names.append(",");
|
||||
|
||||
int begin = 0;
|
||||
int end;
|
||||
int length;
|
||||
|
||||
while ((end = names.find_first_of(',', begin)) != std::string::npos)
|
||||
{
|
||||
length = end - begin;
|
||||
|
||||
if (length > 0)
|
||||
{
|
||||
std::string path = "game\\" + names.substr(begin, length) + ".msg";
|
||||
MSGList* list = new MSGList;
|
||||
|
||||
if (LoadMsgList(list, (char*)path.data()) == 1)
|
||||
gExtraGameMsgLists.insert(std::make_pair(0x2000 + gExtraGameMsgLists.size(), list));
|
||||
}
|
||||
|
||||
begin = end + 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void NewGame2() {
|
||||
ResetState(0);
|
||||
|
||||
@@ -298,6 +338,8 @@ static void NewGame2() {
|
||||
*(DWORD*)0x00672E04=1;
|
||||
}
|
||||
|
||||
ReadExtraGameMsgFiles();
|
||||
|
||||
LoadGlobalScripts();
|
||||
CritLoad();
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "ScriptArrays.hpp"
|
||||
#include "FileSystem.h"
|
||||
#include "Arrays.h"
|
||||
#include "Message.h"
|
||||
|
||||
static void __declspec(naked) funcSqrt() {
|
||||
__asm {
|
||||
@@ -870,6 +871,21 @@ static void _stdcall op_message_str_game2() {
|
||||
else if (fileId >= 0x1000 && fileId <= 0x1005) { // proto msg files
|
||||
msg = GetMessageStr((DWORD)&proto_msg_files[2*(fileId - 0x1000)], msgId);
|
||||
}
|
||||
else if (fileId >= 0x2000) // Extra game message files.
|
||||
{
|
||||
std::unordered_map<int, MSGList*>::iterator it
|
||||
= gExtraGameMsgLists.find(fileId);
|
||||
|
||||
if (it != gExtraGameMsgLists.end())
|
||||
{
|
||||
msg = GetMsg(it->second, msgId, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = 0;
|
||||
SetOpReturn(0, DATATYPE_INT);
|
||||
}
|
||||
}
|
||||
if (msg != 0)
|
||||
SetOpReturn(msg);
|
||||
else
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
#include "Tiles.h"
|
||||
#include "timer.h"
|
||||
#include "version.h"
|
||||
#include "Message.h"
|
||||
|
||||
bool IsDebug = false;
|
||||
|
||||
@@ -1542,7 +1543,19 @@ static void DllMain2() {
|
||||
dlogr("Leave DllMain2", DL_MAIN);
|
||||
}
|
||||
|
||||
void ClearExtraGameMsgFiles()
|
||||
{
|
||||
std::unordered_map<int, MSGList*>::iterator it;
|
||||
|
||||
for (it = gExtraGameMsgLists.begin(); it != gExtraGameMsgLists.end(); ++it)
|
||||
{
|
||||
DestroyMsgList(it->second);
|
||||
delete it->second;
|
||||
}
|
||||
}
|
||||
|
||||
static void _stdcall OnExit() {
|
||||
ClearExtraGameMsgFiles();
|
||||
ConsoleExit();
|
||||
AnimationsAtOnceExit();
|
||||
HeroAppearanceModExit();
|
||||
|
||||
Reference in New Issue
Block a user