Skip to content

Commit

Permalink
game: use semicolon as model path separation
Browse files Browse the repository at this point in the history
Use semicolon in model path for separation models for entity class
with several models, e.g.: head, body, legs.
  • Loading branch information
0lvin committed Oct 1, 2024
1 parent 711d075 commit 4196a61
Showing 1 changed file with 41 additions and 4 deletions.
45 changes: 41 additions & 4 deletions src/game/g_spawn.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ static spawn_t spawns[] = {
typedef struct
{
char classname[MAX_QPATH];
char model_path[MAX_QPATH];
/* could be up to three models */
char model_path[MAX_QPATH * 3];
vec3_t scale;
char entity_type[MAX_QPATH];
vec3_t mins;
Expand Down Expand Up @@ -76,7 +77,41 @@ static void
DynamicSpawnUpdate(edict_t *self, dynamicentity_t *data)
{
/* update properties by dynamic properties */
self->s.modelindex = gi.modelindex(data->model_path);
char model_path[MAX_QPATH * 3];
char *semicolon, *curr;

strncpy(model_path, data->model_path, sizeof(model_path));

/* first model */
curr = model_path;
semicolon = strchr(curr, ';');
if (semicolon)
{
*semicolon = 0;
semicolon ++;
}

self->s.modelindex = gi.modelindex(curr);

/* second model */
if (semicolon)
{
curr = semicolon;
semicolon = strchr(curr, ';');
if (semicolon)
{
*semicolon = 0;
semicolon ++;
}
self->s.modelindex2 = gi.modelindex(curr);
}

/* third model */
if (semicolon)
{
curr = semicolon;
self->s.modelindex3 = gi.modelindex(curr);
}

VectorCopy(data->mins, self->mins);
VectorCopy(data->maxs, self->maxs);
Expand Down Expand Up @@ -1944,7 +1979,8 @@ DynamicSpawnInit(void)

line = curr;
line = DynamicStringParse(line, dynamicentities[curr_pos].classname, MAX_QPATH, ',');
line = DynamicStringParse(line, dynamicentities[curr_pos].model_path, MAX_QPATH, ',');
line = DynamicStringParse(line, dynamicentities[curr_pos].model_path,
sizeof(dynamicentities[curr_pos].model_path), ',');
/*
* Skipped:
* audio file definition
Expand Down Expand Up @@ -2047,7 +2083,8 @@ DynamicSpawnInit(void)

line = curr;
line = DynamicStringParse(line, dynamicentities[curr_pos].classname, MAX_QPATH, '|');
line = DynamicStringParse(line, dynamicentities[curr_pos].model_path, MAX_QPATH, '|');
line = DynamicStringParse(line, dynamicentities[curr_pos].model_path,
sizeof(dynamicentities[curr_pos].model_path), '|');
line = DynamicFloatParse(line, dynamicentities[curr_pos].scale, 3, '|');
line = DynamicStringParse(line, dynamicentities[curr_pos].entity_type, MAX_QPATH, '|');
line = DynamicFloatParse(line, dynamicentities[curr_pos].mins, 3, '|');
Expand Down

0 comments on commit 4196a61

Please sign in to comment.