Files
Cyd 2b8ca921cb Initial full mirror of c:\VWE (source + assets + toolchain + outputs) via Git LFS
Complete disaster-recovery snapshot: engine/game source, game data assets,
VC6 toolchain + DX SDKs, build outputs, deployed game, and _UNUSED archive.
Large binaries in Git LFS; text preserved byte-for-byte (core.autocrlf=false,
no eol attributes). See RECOVERY.md for the one-clone rebuild procedure.
2026-06-24 21:28:16 -05:00

136 lines
2.1 KiB
C++

#include "stdafx.h"
#include "contents.hpp"
CString mattable[19] = {
"grass",
"water",
"concrete",
"greydirt",
"browndirt",
"rock",
"darkconcrete",
"darkgreydirt",
"darkbrowndirt",
"darkrock",
"blacktop",
"snow",
"wood",
"lava",
"glass",
"steel",
"us",
"them",
"blank"
};
CContentData::CContentData (CString& path)
{
m_Path = path;
m_Dirty = false;
}
CContentData::~CContentData (void)
{
}
void CContentData::ReadData (CString file)
{
m_File = file;
CString filename;
char *buf;
CString fred,effect,mat,str;
int index,find;
filename = m_Path;
filename += "\\";
filename += m_File;
buf = fred.GetBufferSetLength (10000);
GetPrivateProfileSection ("EffectList",buf,10000-1,(LPCTSTR) filename);
index = 0;
while (*buf)
{
str = buf;
buf += str.GetLength ()+1;
StripComment (str);
if (!str.IsEmpty ())
{
find = str.Find ('=');
ASSERT (find != -1);
str = str.Right (str.GetLength () - find-1);
find = str.Find (',');
ASSERT (find != -1);
effect = str.Left (find);
mat = str.Right (str.GetLength () - find-1);
index = FindMatIndex (mat);
ASSERT (index != -1);
effect.MakeLower ();
m_EffectName[index] = effect;
}
}
fred.ReleaseBuffer ();
}
int CContentData::FindMatIndex (CString& mat)
{
mat.MakeLower ();
int i;
for (i=0;i<18;i++)
{
if (mat == mattable[i])
return i;
}
return 18;
}
void CContentData::WriteData (void)
{
if (!m_Dirty)
return;
FILE *file;
CString filename;
filename = m_Path;
filename += "\\";
filename += m_File;
file = fopen ((LPCTSTR) filename,"w");
if (!file)
return;
fprintf (file,"[EffectList]\n");
int i;
for (i=0;i<32;i++)
{
if (mattable[i] == "blank")
continue;
fprintf (file,"Effect=%s,%s\n",m_EffectName[i],mattable[i]);
}
fclose (file);
}
void CContentData::InitialData (CString file)
{
m_File = file;
}
void CContentData::StripComment (CString& str)
{
int index;
str.TrimLeft ();
str.TrimRight ();
index = str.Find ("//");
if (index != -1)
{
str = str.Left (index);
}
}