Skip to content

Commit 4fc5e34

Browse files
committed
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).
1 parent c35fbf1 commit 4fc5e34

File tree

8 files changed

+26
-35
lines changed

8 files changed

+26
-35
lines changed

code/cgame/cgame.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@
1818
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
1919
<ConfigurationType>DynamicLibrary</ConfigurationType>
2020
<UseOfMfc>false</UseOfMfc>
21+
<PlatformToolset>v110</PlatformToolset>
2122
</PropertyGroup>
2223
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
2324
<ConfigurationType>DynamicLibrary</ConfigurationType>
2425
<UseOfMfc>false</UseOfMfc>
26+
<PlatformToolset>v110</PlatformToolset>
2527
</PropertyGroup>
2628
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
2729
<ImportGroup Label="ExtensionSettings">

code/game/g_active.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,6 @@ list_iter_p iterTimedMessages;
512512
*/
513513
static char *TimedMessage( void ){
514514
char* message;
515-
timedMessage_t *msg;
516515
container_p c;
517516

518517
if(!level.timedMessages->length) {
@@ -527,8 +526,7 @@ static char *TimedMessage( void ){
527526
}
528527

529528
c = list_cycl_next(iterTimedMessages);
530-
msg = c->data;
531-
message = msg->message;
529+
message = c->data;
532530

533531
return message;
534532
}

code/game/g_cmds.c

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7432,40 +7432,33 @@ void Cmd_CamtestEnd_f(gentity_t *ent) {
74327432
}
74337433
// END CCAM
74347434

7435-
typedef struct rShader_s {
7436-
char *s;
7437-
} rShader_s;
74387435
void addShaderToList(list_p list, char *shader) {
7439-
rShader_s* s = (rShader_s *)malloc(sizeof(rShader_s));
7440-
rShader_s* t;
7436+
char* s;
7437+
char* t;
74417438
container_p c;
74427439
list_iter_p i;
74437440

7444-
if(s == NULL) return;
74457441
if(shader[0] == 0) return;
74467442
if(list == NULL) return;
74477443

7448-
s->s = strdup(shader);
7449-
if(s->s == NULL) {
7450-
free(s);
7444+
s = strdup(shader);
7445+
if(s == NULL) {
74517446
return;
74527447
}
74537448

74547449
i = list_iterator(list, LIST_FRONT);
74557450
if(i == NULL) {
7456-
free(s->s);
7457-
free(s);
74587451
return;
74597452
}
74607453

74617454
for(c = list_next(i)->data; c != NULL; c = list_next(i)->data) {
74627455
t = c->data;
7463-
if(!strcmp(shader, t->s)) {
7456+
if(!strcmp(shader, t)) {
74647457
return;
74657458
}
74667459
}
74677460

7468-
list_append(list, s, LT_DATA, sizeof(rShader_s));
7461+
list_append(list, s, LT_DATA, strlen(s)+1);
74697462
}
74707463

74717464
extern target_alert_Shaders_s alertShaders;
@@ -7477,7 +7470,7 @@ void Cmd_GeneratePrecacheFile(gentity_t *ent) {
74777470
list_iter_p iter;
74787471
qboolean first = qtrue;
74797472
fileHandle_t f;
7480-
rShader_s* s;
7473+
char* s;
74817474
container_p c;
74827475

74837476
trap_GetServerinfo(info, MAX_INFO_STRING);
@@ -7531,15 +7524,15 @@ void Cmd_GeneratePrecacheFile(gentity_t *ent) {
75317524

75327525
for(c = list_next(iter)->data; c != NULL; c = list_next(iter)->data) {
75337526
s = c->data;
7534-
G_Printf("\t%s\n", s->s);
7527+
G_Printf("\t%s\n", s);
75357528
if(first) {
75367529
trap_FS_Write("\"", 1, f);
7537-
trap_FS_Write(s->s, strlen(s->s), f);
7530+
trap_FS_Write(s, strlen(s), f);
75387531
trap_FS_Write("\"", 1, f);
75397532
first = qfalse;
75407533
} else {
75417534
trap_FS_Write("\n\"", 2, f);
7542-
trap_FS_Write(s->s, strlen(s->s), f);
7535+
trap_FS_Write(s, strlen(s), f);
75437536
trap_FS_Write("\"", 1, f);
75447537
}
75457538
}

code/game/g_local.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2092,12 +2092,6 @@ struct luaAlertState_s {
20922092

20932093
luaAlertState_t* luaAlertState;
20942094

2095-
// timed messages
2096-
typedef struct timedMessage_s timedMessage_t;
2097-
struct timedMessage_s {
2098-
char* message;
2099-
} timedMessage_s;
2100-
21012095
/* alert shaders */
21022096
typedef struct {
21032097
char* greenShaders[10];

code/game/g_main.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,6 @@ static void G_LoadTimedMessages(void) {
915915
char* token;
916916
int len;
917917
int i;
918-
timedMessage_t *msg;
919918

920919
len = trap_FS_FOpenFile("timedmessages.cfg", &f, FS_READ);
921920
if(!len) return;
@@ -961,14 +960,7 @@ static void G_LoadTimedMessages(void) {
961960
continue;
962961
}
963962

964-
msg = (timedMessage_t *)malloc(sizeof(timedMessage_s));
965-
if(msg == NULL) {
966-
G_Printf("G_LoadTimedMessages - was unable to allocate timed message storage\n");
967-
continue;
968-
}
969-
970-
msg->message = strdup(token);
971-
list_append(level.timedMessages, msg, LT_DATA, sizeof(timedMessage_s));
963+
list_append(level.timedMessages, token, LT_DATA, strlen(token)+1);
972964
} else {
973965
if(token[0] == '}') {
974966
break;

code/game/game.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@
1818
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
1919
<ConfigurationType>DynamicLibrary</ConfigurationType>
2020
<UseOfMfc>false</UseOfMfc>
21+
<PlatformToolset>v110</PlatformToolset>
2122
</PropertyGroup>
2223
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
2324
<ConfigurationType>DynamicLibrary</ConfigurationType>
2425
<UseOfMfc>false</UseOfMfc>
26+
<PlatformToolset>v110</PlatformToolset>
2527
</PropertyGroup>
2628
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
2729
<ImportGroup Label="ExtensionSettings">

code/ui/ui.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@
1919
<ConfigurationType>DynamicLibrary</ConfigurationType>
2020
<UseOfMfc>false</UseOfMfc>
2121
<CharacterSet>MultiByte</CharacterSet>
22+
<PlatformToolset>v110</PlatformToolset>
2223
</PropertyGroup>
2324
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
2425
<ConfigurationType>DynamicLibrary</ConfigurationType>
2526
<UseOfMfc>false</UseOfMfc>
2627
<CharacterSet>MultiByte</CharacterSet>
28+
<PlatformToolset>v110</PlatformToolset>
2729
</PropertyGroup>
2830
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
2931
<ImportGroup Label="ExtensionSettings">

misc/msvc10/quake3.vcxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,34 +41,42 @@
4141
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug TA|Win32'" Label="Configuration">
4242
<ConfigurationType>Application</ConfigurationType>
4343
<UseOfMfc>false</UseOfMfc>
44+
<PlatformToolset>v110</PlatformToolset>
4445
</PropertyGroup>
4546
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug TA|x64'" Label="Configuration">
4647
<ConfigurationType>Application</ConfigurationType>
4748
<UseOfMfc>false</UseOfMfc>
49+
<PlatformToolset>v110</PlatformToolset>
4850
</PropertyGroup>
4951
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
5052
<ConfigurationType>Application</ConfigurationType>
5153
<UseOfMfc>Static</UseOfMfc>
54+
<PlatformToolset>v110</PlatformToolset>
5255
</PropertyGroup>
5356
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
5457
<ConfigurationType>Application</ConfigurationType>
5558
<UseOfMfc>Static</UseOfMfc>
59+
<PlatformToolset>v110</PlatformToolset>
5660
</PropertyGroup>
5761
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
5862
<ConfigurationType>Application</ConfigurationType>
5963
<UseOfMfc>false</UseOfMfc>
64+
<PlatformToolset>v110</PlatformToolset>
6065
</PropertyGroup>
6166
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
6267
<ConfigurationType>Application</ConfigurationType>
6368
<UseOfMfc>false</UseOfMfc>
69+
<PlatformToolset>v110</PlatformToolset>
6470
</PropertyGroup>
6571
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release TA|Win32'" Label="Configuration">
6672
<ConfigurationType>Application</ConfigurationType>
6773
<UseOfMfc>Static</UseOfMfc>
74+
<PlatformToolset>v110</PlatformToolset>
6875
</PropertyGroup>
6976
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release TA|x64'" Label="Configuration">
7077
<ConfigurationType>Application</ConfigurationType>
7178
<UseOfMfc>Static</UseOfMfc>
79+
<PlatformToolset>v110</PlatformToolset>
7280
</PropertyGroup>
7381
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
7482
<ImportGroup Label="ExtensionSettings">

0 commit comments

Comments
 (0)