Split STRTAB further into STRTAB and CONVERSATION

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2974 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
mcmartin
2008-05-15 07:17:32 +00:00
parent 38b00505d5
commit ded11e540e
6 changed files with 215 additions and 79 deletions
+1
View File
@@ -1,4 +1,5 @@
Changes towards version 0.7:
- Split STRTAB further into STRTAB and CONVERSATION - Michael
- INT32, BOOLEAN, and STRING resource types - Michael
- UNKNOWNRES is now safe to load, and "loads" as its resvalue - Michael
- CODE is now SHIP, and uses an integer descriptor instead of a one-byte
+27 -27
View File
@@ -5,128 +5,128 @@ colortable.ip_sun = BINTAB:ipanims/ip_sun.ct
colortable.orbplan = BINTAB:ipanims/orbplan.ct
colortable.scclrtab = BINTAB:lbm/scclrtab.ct
comm.arilou.colortable = BINTAB:comm/arilou/arilou.ct
comm.arilou.dialogue = STRTAB:comm/arilou/arilou.txt
comm.arilou.dialogue = CONVERSATION:comm/arilou/arilou.txt
comm.arilou.font = FONTRES:comm/arilou/arilou.fon
comm.arilou.graphics = GFXRES:comm/arilou/arilou.ani
comm.arilou.music = MUSICRES:comm/arilou/arilou.mod
comm.chmmr.colortable = BINTAB:comm/chmmr/chmmr.ct
comm.chmmr.dialogue = STRTAB:comm/chmmr/chmmr.txt
comm.chmmr.dialogue = CONVERSATION:comm/chmmr/chmmr.txt
comm.chmmr.font = FONTRES:comm/chmmr/chmmr.fon
comm.chmmr.graphics = GFXRES:comm/chmmr/chmmr.ani
comm.chmmr.music = MUSICRES:comm/chmmr/chmmr.mod
comm.commander.colortable = BINTAB:comm/comandr/comandr.ct
comm.commander.dialogue = STRTAB:comm/comandr/comandr.txt
comm.commander.dialogue = CONVERSATION:comm/comandr/comandr.txt
comm.commander.font = FONTRES:comm/comandr/comandr.fon
comm.commander.graphics = GFXRES:comm/comandr/comandr.ani
comm.commander.music = MUSICRES:comm/comandr/comandr.mod
comm.druuge.colortable = BINTAB:comm/druuge/druuge.ct
comm.druuge.dialogue = STRTAB:comm/druuge/druuge.txt
comm.druuge.dialogue = CONVERSATION:comm/druuge/druuge.txt
comm.druuge.font = FONTRES:comm/druuge/druuge.fon
comm.druuge.graphics = GFXRES:comm/druuge/druuge.ani
comm.druuge.music = MUSICRES:comm/druuge/druuge.mod
comm.ilwrath.colortable = BINTAB:comm/ilwrath/ilwrath.ct
comm.ilwrath.dialogue = STRTAB:comm/ilwrath/ilwrath.txt
comm.ilwrath.dialogue = CONVERSATION:comm/ilwrath/ilwrath.txt
comm.ilwrath.font = FONTRES:comm/ilwrath/ilwrath.fon
comm.ilwrath.graphics = GFXRES:comm/ilwrath/ilwrath.ani
comm.ilwrath.music = MUSICRES:comm/ilwrath/ilwrath.mod
comm.kohrah.colortable = BINTAB:comm/blackur/blackur.ct
comm.kohrah.dialogue = STRTAB:comm/blackur/blackur.txt
comm.kohrah.dialogue = CONVERSATION:comm/blackur/blackur.txt
comm.kohrah.font = FONTRES:comm/blackur/blackur.fon
comm.kohrah.graphics = GFXRES:comm/blackur/blackur.ani
comm.kohrah.music = MUSICRES:comm/blackur/blackur.mod
comm.melnorme.colortable = BINTAB:comm/melnorm/melnorm.ct
comm.melnorme.dialogue = STRTAB:comm/melnorm/melnorm.txt
comm.melnorme.dialogue = CONVERSATION:comm/melnorm/melnorm.txt
comm.melnorme.font = FONTRES:comm/melnorm/melnorm.fon
comm.melnorme.graphics = GFXRES:comm/melnorm/melnorm.ani
comm.melnorme.music = MUSICRES:comm/melnorm/melnorm.mod
comm.mycon.colortable = BINTAB:comm/mycon/mycon.ct
comm.mycon.dialogue = STRTAB:comm/mycon/mycon.txt
comm.mycon.dialogue = CONVERSATION:comm/mycon/mycon.txt
comm.mycon.font = FONTRES:comm/mycon/mycon.fon
comm.mycon.graphics = GFXRES:comm/mycon/mycon.ani
comm.mycon.music = MUSICRES:comm/mycon/mycon.mod
comm.orz.colortable = BINTAB:comm/orz/orz.ct
comm.orz.dialogue = STRTAB:comm/orz/orz.txt
comm.orz.dialogue = CONVERSATION:comm/orz/orz.txt
comm.orz.font = FONTRES:comm/orz/orz.fon
comm.orz.graphics = GFXRES:comm/orz/orz.ani
comm.orz.music = MUSICRES:comm/orz/orz.mod
comm.pkunk.colortable = BINTAB:comm/pkunk/pkunk.ct
comm.pkunk.dialogue = STRTAB:comm/pkunk/pkunk.txt
comm.pkunk.dialogue = CONVERSATION:comm/pkunk/pkunk.txt
comm.pkunk.font = FONTRES:comm/pkunk/pkunk.fon
comm.pkunk.graphics = GFXRES:comm/pkunk/pkunk.ani
comm.pkunk.music = MUSICRES:comm/pkunk/pkunk.mod
comm.shofixti.colortable = BINTAB:comm/shofixt/shofixt.ct
comm.shofixti.dialogue = STRTAB:comm/shofixt/shofixt.txt
comm.shofixti.dialogue = CONVERSATION:comm/shofixt/shofixt.txt
comm.shofixti.font = FONTRES:comm/shofixt/shofixt.fon
comm.shofixti.graphics = GFXRES:comm/shofixt/shofixt.ani
comm.shofixti.music = MUSICRES:comm/shofixt/shofixt.mod
comm.slyhome.colortable = BINTAB:comm/slyhome/slyhome.ct
comm.slyhome.dialogue = STRTAB:comm/slyhome/slyhome.txt
comm.slyhome.dialogue = CONVERSATION:comm/slyhome/slyhome.txt
comm.slyhome.font = FONTRES:comm/slyhome/slyhome.fon
comm.slyhome.graphics = GFXRES:comm/slyhome/slyhome.ani
comm.slyhome.music = MUSICRES:comm/slyhome/slyhome.mod
comm.slylandro.colortable = BINTAB:comm/slyland/slyland.ct
comm.slylandro.dialogue = STRTAB:comm/slyland/slyland.txt
comm.slylandro.dialogue = CONVERSATION:comm/slyland/slyland.txt
comm.slylandro.font = FONTRES:comm/slyland/slyland.fon
comm.slylandro.graphics = GFXRES:comm/slyland/slyland.ani
comm.slylandro.music = MUSICRES:comm/slyland/slyland.mod
comm.spahome.colortable = BINTAB:comm/spahome/spahome.ct
comm.spahome.dialogue = STRTAB:comm/spahome/spahome.txt
comm.spahome.dialogue = CONVERSATION:comm/spahome/spahome.txt
comm.spahome.graphics = GFXRES:comm/spahome/spahome.ani
comm.spahome.music = MUSICRES:comm/spathi/spathi.mod
comm.spathi.colortable = BINTAB:comm/spathi/spathi.ct
comm.spathi.dialogue = STRTAB:comm/spathi/spathi.txt
comm.spathi.dialogue = CONVERSATION:comm/spathi/spathi.txt
comm.spathi.font = FONTRES:comm/spathi/spathi.fon
comm.spathi.graphics = GFXRES:comm/spathi/spathi.ani
comm.spathi.music = MUSICRES:comm/spathi/spathi.mod
comm.starbase.dialogue = STRTAB:comm/starbas/starbas.txt
comm.starbase.dialogue = CONVERSATION:comm/starbas/starbas.txt
comm.supox.colortable = BINTAB:comm/supox/supox.ct
comm.supox.dialogue = STRTAB:comm/supox/supox.txt
comm.supox.dialogue = CONVERSATION:comm/supox/supox.txt
comm.supox.font = FONTRES:comm/supox/supox.fon
comm.supox.graphics = GFXRES:comm/supox/supox.ani
comm.supox.music = MUSICRES:comm/supox/supox.mod
comm.syreen.colortable = BINTAB:comm/syreen/syreen.ct
comm.syreen.dialogue = STRTAB:comm/syreen/syreen.txt
comm.syreen.dialogue = CONVERSATION:comm/syreen/syreen.txt
comm.syreen.font = FONTRES:comm/syreen/syreen.fon
comm.syreen.graphics = GFXRES:comm/syreen/syreen.ani
comm.syreen.music = MUSICRES:comm/syreen/syreen.mod
comm.talkingpet.colortable = BINTAB:comm/talkpet/talkpet.ct
comm.talkingpet.dialogue = STRTAB:comm/talkpet/talkpet.txt
comm.talkingpet.dialogue = CONVERSATION:comm/talkpet/talkpet.txt
comm.talkingpet.font = FONTRES:comm/talkpet/talkpet.fon
comm.talkingpet.graphics = GFXRES:comm/talkpet/talkpet.ani
comm.talkingpet.music = MUSICRES:comm/talkpet/talkpet.mod
comm.thraddash.colortable = BINTAB:comm/thradd/thradd.ct
comm.thraddash.dialogue = STRTAB:comm/thradd/thradd.txt
comm.thraddash.dialogue = CONVERSATION:comm/thradd/thradd.txt
comm.thraddash.font = FONTRES:comm/thradd/thradd.fon
comm.thraddash.graphics = GFXRES:comm/thradd/thradd.ani
comm.thraddash.music = MUSICRES:comm/thradd/thradd.mod
comm.umgah.colortable = BINTAB:comm/umgah/umgah.ct
comm.umgah.dialogue = STRTAB:comm/umgah/umgah.txt
comm.umgah.dialogue = CONVERSATION:comm/umgah/umgah.txt
comm.umgah.font = FONTRES:comm/umgah/umgah.fon
comm.umgah.graphics = GFXRES:comm/umgah/umgah.ani
comm.umgah.music = MUSICRES:comm/umgah/umgah.mod
comm.urquan.colortable = BINTAB:comm/urquan/urquan.ct
comm.urquan.dialogue = STRTAB:comm/urquan/urquan.txt
comm.urquan.dialogue = CONVERSATION:comm/urquan/urquan.txt
comm.urquan.font = FONTRES:comm/urquan/urquan.fon
comm.urquan.graphics = GFXRES:comm/urquan/urquan.ani
comm.urquan.music = MUSICRES:comm/urquan/urquan.mod
comm.utwig.colortable = BINTAB:comm/utwig/utwig.ct
comm.utwig.dialogue = STRTAB:comm/utwig/utwig.txt
comm.utwig.dialogue = CONVERSATION:comm/utwig/utwig.txt
comm.utwig.font = FONTRES:comm/utwig/utwig.fon
comm.utwig.graphics = GFXRES:comm/utwig/utwig.ani
comm.utwig.music = MUSICRES:comm/utwig/utwig.mod
comm.vux.colortable = BINTAB:comm/vux/vux.ct
comm.vux.dialogue = STRTAB:comm/vux/vux.txt
comm.vux.dialogue = CONVERSATION:comm/vux/vux.txt
comm.vux.font = FONTRES:comm/vux/vux.fon
comm.vux.graphics = GFXRES:comm/vux/vux.ani
comm.vux.music = MUSICRES:comm/vux/vux.mod
comm.yehat.colortable = BINTAB:comm/yehat/yehat.ct
comm.yehat.dialogue = STRTAB:comm/yehat/yehat.txt
comm.yehat.dialogue = CONVERSATION:comm/yehat/yehat.txt
comm.yehat.font = FONTRES:comm/yehat/yehat.fon
comm.yehat.graphics = GFXRES:comm/yehat/yehat.ani
comm.yehat.music = MUSICRES:comm/yehat/yehat.mod
comm.yehat.rebel.dialogue = STRTAB:comm/rebel/rebel.txt
comm.yehat.rebel.dialogue = CONVERSATION:comm/rebel/rebel.txt
comm.zoqfotpik.colortable = BINTAB:comm/zoqfot/zoqfot.ct
comm.zoqfotpik.dialogue = STRTAB:comm/zoqfot/zoqfot.txt
comm.zoqfotpik.dialogue = CONVERSATION:comm/zoqfot/zoqfot.txt
comm.zoqfotpik.font = FONTRES:comm/zoqfot/zoqfot.fon
comm.zoqfotpik.graphics = GFXRES:comm/zoqfot/zoqfot.ani
comm.zoqfotpik.music = MUSICRES:comm/zoqfot/zoqfot.mod
+158 -25
View File
@@ -22,6 +22,8 @@
#include "libs/reslib.h"
#include "libs/log.h"
#define MAX_STRINGS 2048
#define POOL_SIZE 4096
static void
dword_convert (DWORD *dword_array, COUNT num_dwords)
@@ -57,44 +59,60 @@ set_strtab_entry (STRING_TABLE_DESC *strtab, int index, const char *value, int l
}
}
void *
_GetStringData (uio_Stream *fp, DWORD length)
void
_GetConversationData (const char *path, RESOURCE_DATA *resdata)
{
uio_Stream *fp;
long dataLen;
void *result;
#define MAX_STRINGS 2048
#define POOL_SIZE 4096
fp = res_OpenResFile (contentDir, path, "rb");
if (fp == NULL)
{
log_add (log_Warning, "Warning: Can't open '%s'", path);
resdata->ptr = NULL;
return;
}
dataLen = LengthResFile (fp);
log_add (log_Info, "\t'%s' -- %lu bytes in Conversation", path, dataLen);
if (dataLen == 0)
{
log_add (log_Warning, "Warning: Trying to load empty file '%s'.", path);
goto err;
}
int n, path_len, num_data_sets;
DWORD opos,
slen[MAX_STRINGS], StringOffs, tot_string_size,
clen[MAX_STRINGS], ClipOffs, tot_clip_size,
tslen[MAX_STRINGS], TSOffs, tot_ts_size;
slen[MAX_STRINGS], StringOffs, tot_string_size,
clen[MAX_STRINGS], ClipOffs, tot_clip_size,
tslen[MAX_STRINGS], TSOffs, tot_ts_size;
char CurrentLine[1024], clip_path[1024], *strdata, *clipdata,
*ts_data;
*ts_data;
uio_Stream *timestamp_fp = NULL;
if ((strdata = HMalloc (tot_string_size = POOL_SIZE)) == 0)
return (0);
goto err;
if ((clipdata = HMalloc (tot_clip_size = POOL_SIZE)) == 0)
{
HFree (strdata);
return (0);
goto err;
}
ts_data = NULL;
{
char *s1, *s2;
if (((s2 = 0), (s1 = strrchr (_cur_resfile_name, '/')) == 0)
&& (s2 = strrchr (_cur_resfile_name, '\\')) == 0)
if (((s2 = 0), (s1 = strrchr (path, '/')) == 0)
&& (s2 = strrchr (path, '\\')) == 0)
n = 0;
else
{
if (s2 > s1)
s1 = s2;
n = s1 - _cur_resfile_name + 1;
strncpy (clip_path, _cur_resfile_name, n);
n = s1 - path + 1;
strncpy (clip_path, path, n);
}
clip_path[n] = '\0';
path_len = strlen (clip_path);
@@ -104,20 +122,20 @@ _GetStringData (uio_Stream *fp, DWORD length)
// try to open the timestamp file
char ts_file_name[1024];
char *s;
strcpy (ts_file_name, _cur_resfile_name);
strcpy (ts_file_name, path);
s = strrchr (ts_file_name, '.');
s += 2;
*s++ = 's';
*s = '\0';
if ((timestamp_fp = uio_fopen (contentDir, ts_file_name,
"rb")))
"rb")))
{
log_add (log_Info, "Found timestamp file: %s", ts_file_name);
if ((ts_data = HMalloc (tot_ts_size = POOL_SIZE)) == 0)
return (0);
goto err;
}
}
opos = uio_ftell (fp);
n = -1;
StringOffs = ClipOffs = TSOffs = 0;
@@ -171,7 +189,7 @@ _GetStringData (uio_Stream *fp, DWORD length)
tot_ts_size += POOL_SIZE)) == 0)
{
HFree (strdata);
return (0);
goto err;
}
strcpy (&ts_data[TSOffs], tsptr);
TSOffs += l;
@@ -201,7 +219,7 @@ _GetStringData (uio_Stream *fp, DWORD length)
tot_clip_size += POOL_SIZE)) == 0)
{
HFree (strdata);
return (0);
goto err;
}
strcpy (&clipdata[ClipOffs], clip_path);
@@ -220,7 +238,7 @@ _GetStringData (uio_Stream *fp, DWORD length)
tot_string_size += POOL_SIZE)) == 0)
{
HFree (clipdata);
return (0);
goto err;
}
if (slen[n])
@@ -235,7 +253,7 @@ _GetStringData (uio_Stream *fp, DWORD length)
strcpy (s, CurrentLine);
}
if ((int)uio_ftell (fp) - (int)opos >= (int)length)
if ((int)uio_ftell (fp) - (int)opos >= (int)dataLen)
break;
}
if (n >= 0)
@@ -298,6 +316,121 @@ _GetStringData (uio_Stream *fp, DWORD length)
if (ts_data)
HFree (ts_data);
resdata->ptr = result;
return;
err:
res_CloseResFile (fp);
resdata->ptr = NULL;
}
void *
_GetStringData (uio_Stream *fp, DWORD length)
{
void *result;
int n;
DWORD opos, slen[MAX_STRINGS], StringOffs, tot_string_size;
char CurrentLine[1024], *strdata;
if ((strdata = HMalloc (tot_string_size = POOL_SIZE)) == 0)
return (0);
opos = uio_ftell (fp);
n = -1;
StringOffs = 0;
while (uio_fgets (CurrentLine, sizeof (CurrentLine), fp) && n < MAX_STRINGS - 1)
{
int l;
if (CurrentLine[0] == '#')
{
char CopyLine[1024];
char *s;
strcpy (CopyLine, CurrentLine);
s = strtok (&CopyLine[1], "()");
if (s)
{
if (n >= 0)
{
while (slen[n] > 1 &&
(strdata[StringOffs - 2] == '\n' ||
strdata[StringOffs - 2] == '\r'))
{
--slen[n];
--StringOffs;
strdata[StringOffs - 1] = '\0';
}
}
slen[++n] = 0;
}
}
else if (n >= 0)
{
char *s;
l = strlen (CurrentLine) + 1;
if (StringOffs + l > tot_string_size
&& (strdata = HRealloc (strdata,
tot_string_size += POOL_SIZE)) == 0)
{
return (0);
}
if (slen[n])
{
--slen[n];
--StringOffs;
}
s = &strdata[StringOffs];
slen[n] += l;
StringOffs += l;
strcpy (s, CurrentLine);
}
if ((int)uio_ftell (fp) - (int)opos >= (int)length)
break;
}
if (n >= 0)
{
while (slen[n] > 1 && (strdata[StringOffs - 2] == '\n'
|| strdata[StringOffs - 2] == '\r'))
{
--slen[n];
--StringOffs;
strdata[StringOffs - 1] = '\0';
}
}
result = NULL;
if (++n)
{
int flags = 0;
result = AllocStringTable (n, flags);
if (result)
{
int StringIndex;
STRING_TABLE_DESC *lpST;
lpST = (STRING_TABLE) result;
StringIndex = 0;
StringOffs = 0;
for (n = 0; n < (int)lpST->size;
++n, ++StringIndex)
{
set_strtab_entry(lpST, StringIndex, strdata + StringOffs, slen[n]);
StringOffs += slen[n];
}
}
}
HFree (strdata);
return (result);
}
+1
View File
@@ -35,6 +35,7 @@ InstallStringTableResType (void)
{
InstallResTypeVectors ("STRTAB", GetStringTableFileData, FreeResourceData);
InstallResTypeVectors ("BINTAB", GetBinaryTableFileData, FreeResourceData);
InstallResTypeVectors ("CONVERSATION", _GetConversationData, FreeResourceData);
return TRUE;
}
+1
View File
@@ -47,6 +47,7 @@ void FreeStringTable (STRING_TABLE strtab);
void *_GetStringData (uio_Stream *fp, DWORD length);
void *_GetBinaryTableData (uio_Stream *fp, DWORD length);
void _GetConversationData (const char *path, RESOURCE_DATA *resdata);
#endif /* _STRINTRN_H */