Modified some code due to use of container ...

The list now can store C types and and strings directly (without the
need of them to be in a struct).
This commit is contained in:
Walter Julius Hennecke 2013-04-09 22:09:29 +02:00
parent c35fbf170f
commit 4fc5e3489a
8 changed files with 26 additions and 35 deletions

View File

@ -18,10 +18,12 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseOfMfc>false</UseOfMfc> <UseOfMfc>false</UseOfMfc>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseOfMfc>false</UseOfMfc> <UseOfMfc>false</UseOfMfc>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings"> <ImportGroup Label="ExtensionSettings">

View File

@ -512,7 +512,6 @@ list_iter_p iterTimedMessages;
*/ */
static char *TimedMessage( void ){ static char *TimedMessage( void ){
char* message; char* message;
timedMessage_t *msg;
container_p c; container_p c;
if(!level.timedMessages->length) { if(!level.timedMessages->length) {
@ -527,8 +526,7 @@ static char *TimedMessage( void ){
} }
c = list_cycl_next(iterTimedMessages); c = list_cycl_next(iterTimedMessages);
msg = c->data; message = c->data;
message = msg->message;
return message; return message;
} }

View File

@ -7432,40 +7432,33 @@ void Cmd_CamtestEnd_f(gentity_t *ent) {
} }
// END CCAM // END CCAM
typedef struct rShader_s {
char *s;
} rShader_s;
void addShaderToList(list_p list, char *shader) { void addShaderToList(list_p list, char *shader) {
rShader_s* s = (rShader_s *)malloc(sizeof(rShader_s)); char* s;
rShader_s* t; char* t;
container_p c; container_p c;
list_iter_p i; list_iter_p i;
if(s == NULL) return;
if(shader[0] == 0) return; if(shader[0] == 0) return;
if(list == NULL) return; if(list == NULL) return;
s->s = strdup(shader); s = strdup(shader);
if(s->s == NULL) { if(s == NULL) {
free(s);
return; return;
} }
i = list_iterator(list, LIST_FRONT); i = list_iterator(list, LIST_FRONT);
if(i == NULL) { if(i == NULL) {
free(s->s);
free(s);
return; return;
} }
for(c = list_next(i)->data; c != NULL; c = list_next(i)->data) { for(c = list_next(i)->data; c != NULL; c = list_next(i)->data) {
t = c->data; t = c->data;
if(!strcmp(shader, t->s)) { if(!strcmp(shader, t)) {
return; return;
} }
} }
list_append(list, s, LT_DATA, sizeof(rShader_s)); list_append(list, s, LT_DATA, strlen(s)+1);
} }
extern target_alert_Shaders_s alertShaders; extern target_alert_Shaders_s alertShaders;
@ -7477,7 +7470,7 @@ void Cmd_GeneratePrecacheFile(gentity_t *ent) {
list_iter_p iter; list_iter_p iter;
qboolean first = qtrue; qboolean first = qtrue;
fileHandle_t f; fileHandle_t f;
rShader_s* s; char* s;
container_p c; container_p c;
trap_GetServerinfo(info, MAX_INFO_STRING); trap_GetServerinfo(info, MAX_INFO_STRING);
@ -7531,15 +7524,15 @@ void Cmd_GeneratePrecacheFile(gentity_t *ent) {
for(c = list_next(iter)->data; c != NULL; c = list_next(iter)->data) { for(c = list_next(iter)->data; c != NULL; c = list_next(iter)->data) {
s = c->data; s = c->data;
G_Printf("\t%s\n", s->s); G_Printf("\t%s\n", s);
if(first) { if(first) {
trap_FS_Write("\"", 1, f); trap_FS_Write("\"", 1, f);
trap_FS_Write(s->s, strlen(s->s), f); trap_FS_Write(s, strlen(s), f);
trap_FS_Write("\"", 1, f); trap_FS_Write("\"", 1, f);
first = qfalse; first = qfalse;
} else { } else {
trap_FS_Write("\n\"", 2, f); trap_FS_Write("\n\"", 2, f);
trap_FS_Write(s->s, strlen(s->s), f); trap_FS_Write(s, strlen(s), f);
trap_FS_Write("\"", 1, f); trap_FS_Write("\"", 1, f);
} }
} }

View File

@ -2092,12 +2092,6 @@ struct luaAlertState_s {
luaAlertState_t* luaAlertState; luaAlertState_t* luaAlertState;
// timed messages
typedef struct timedMessage_s timedMessage_t;
struct timedMessage_s {
char* message;
} timedMessage_s;
/* alert shaders */ /* alert shaders */
typedef struct { typedef struct {
char* greenShaders[10]; char* greenShaders[10];

View File

@ -915,7 +915,6 @@ static void G_LoadTimedMessages(void) {
char* token; char* token;
int len; int len;
int i; int i;
timedMessage_t *msg;
len = trap_FS_FOpenFile("timedmessages.cfg", &f, FS_READ); len = trap_FS_FOpenFile("timedmessages.cfg", &f, FS_READ);
if(!len) return; if(!len) return;
@ -961,14 +960,7 @@ static void G_LoadTimedMessages(void) {
continue; continue;
} }
msg = (timedMessage_t *)malloc(sizeof(timedMessage_s)); list_append(level.timedMessages, token, LT_DATA, strlen(token)+1);
if(msg == NULL) {
G_Printf("G_LoadTimedMessages - was unable to allocate timed message storage\n");
continue;
}
msg->message = strdup(token);
list_append(level.timedMessages, msg, LT_DATA, sizeof(timedMessage_s));
} else { } else {
if(token[0] == '}') { if(token[0] == '}') {
break; break;

View File

@ -18,10 +18,12 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseOfMfc>false</UseOfMfc> <UseOfMfc>false</UseOfMfc>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseOfMfc>false</UseOfMfc> <UseOfMfc>false</UseOfMfc>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings"> <ImportGroup Label="ExtensionSettings">

View File

@ -19,11 +19,13 @@
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseOfMfc>false</UseOfMfc> <UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet> <CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseOfMfc>false</UseOfMfc> <UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet> <CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings"> <ImportGroup Label="ExtensionSettings">

View File

@ -41,34 +41,42 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug TA|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug TA|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<UseOfMfc>false</UseOfMfc> <UseOfMfc>false</UseOfMfc>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug TA|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug TA|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<UseOfMfc>false</UseOfMfc> <UseOfMfc>false</UseOfMfc>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<UseOfMfc>Static</UseOfMfc> <UseOfMfc>Static</UseOfMfc>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<UseOfMfc>Static</UseOfMfc> <UseOfMfc>Static</UseOfMfc>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<UseOfMfc>false</UseOfMfc> <UseOfMfc>false</UseOfMfc>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<UseOfMfc>false</UseOfMfc> <UseOfMfc>false</UseOfMfc>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release TA|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release TA|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<UseOfMfc>Static</UseOfMfc> <UseOfMfc>Static</UseOfMfc>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release TA|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release TA|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<UseOfMfc>Static</UseOfMfc> <UseOfMfc>Static</UseOfMfc>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings"> <ImportGroup Label="ExtensionSettings">