mirror of
https://github.com/nzp-team/quakespasm.git
synced 2024-11-10 06:32:03 +00:00
NX/VITA: Add support for loading NZ:P Beta Waypoints
This commit is contained in:
parent
73781d4e13
commit
b5150a81e6
1 changed files with 131 additions and 32 deletions
163
source/sv_main.c
163
source/sv_main.c
|
@ -1588,6 +1588,15 @@ int W_fopen (void)
|
|||
return h;
|
||||
}
|
||||
|
||||
int W_fopenbeta(void)
|
||||
{
|
||||
int h = 0;
|
||||
|
||||
Sys_FileOpenRead (va("%s/data/%s",com_gamedir, sv.name), &h);
|
||||
return h;
|
||||
}
|
||||
|
||||
|
||||
void W_fclose (int h)
|
||||
{
|
||||
Sys_FileClose(h);
|
||||
|
@ -1673,6 +1682,96 @@ void W_stov (char *v, vec3_t out)
|
|||
}
|
||||
|
||||
waypoint_ai waypoints[MAX_WAYPOINTS];
|
||||
|
||||
//
|
||||
// Load_Waypoint_NZPBETA
|
||||
// Attempts to load an NZ:P Beta formatted
|
||||
// Waypoint file.
|
||||
//
|
||||
void Load_Waypoint_NZPBETA()
|
||||
{
|
||||
char temp[64];
|
||||
int i, p, s;
|
||||
int h = 0;
|
||||
|
||||
h = W_fopenbeta();
|
||||
|
||||
if (h == -1) {
|
||||
return; // don't bother notifying..
|
||||
}
|
||||
|
||||
for (i = 0; i < MAX_WAYPOINTS; i++)
|
||||
{
|
||||
waypoints[i].used = 0;
|
||||
waypoints[i].id = -1;
|
||||
for (p = 0; p < 8; p++) {
|
||||
waypoints[i].target[p] = -1;
|
||||
waypoints[i].target_id[p] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < MAX_EDICTS; i++)
|
||||
{
|
||||
closest_waypoints[i] = -1;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
Con_DPrintf("Loading BETA waypoints\n");
|
||||
|
||||
vec3_t way_origin;
|
||||
int way_id;
|
||||
|
||||
while (1)
|
||||
{
|
||||
// End of file.
|
||||
if (!strcmp(W_fgets(h), ""))
|
||||
break;
|
||||
|
||||
W_stov(w_string_temp, way_origin); // <origin>
|
||||
way_id = atoi(W_fgets(h)); // <id>
|
||||
|
||||
if (way_id >= MAX_WAYPOINTS)
|
||||
Sys_Error ("Waypoint with id %d past MAX_WAYPOINTS {%i)\n", way_id, MAX_WAYPOINTS);
|
||||
|
||||
waypoints[way_id].id = way_id;
|
||||
VectorCopy(way_origin, waypoints[way_id].origin);
|
||||
|
||||
// <link1> - <link4>, <owner1> - <owner4>
|
||||
for(i = 0; i < 8; i++) {
|
||||
W_fgets(h);
|
||||
|
||||
if (i < 4) {
|
||||
int id = atoi(w_string_temp);
|
||||
if (id > 0) {
|
||||
waypoints[way_id].target[i] = id;
|
||||
waypoints[way_id].target_id[i] = waypoints[way_id].target[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
waypoints[way_id].used = 1;
|
||||
waypoints[way_id].open = 1;
|
||||
}
|
||||
Con_DPrintf("Total waypoints: %i\n", way_id);
|
||||
for (i = 0; i < MAX_WAYPOINTS; i++) //for sake of saving time later we are now going to save each targets array position and distace to each waypoint
|
||||
{
|
||||
for (p = 0; waypoints[i].target[p]; p++)
|
||||
{
|
||||
if (waypoints[i].target[p] < 0) break;
|
||||
|
||||
for (s = 0; s < MAX_WAYPOINTS; s++)
|
||||
{
|
||||
if (waypoints[i].target[p] == s)
|
||||
{
|
||||
waypoints[i].dist[p] = VecLength2(waypoints[s].origin, waypoints[i].origin);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
W_fclose(h);
|
||||
}
|
||||
|
||||
void Load_Waypoint ()
|
||||
{
|
||||
char temp[64];
|
||||
|
@ -1685,7 +1784,8 @@ void Load_Waypoint ()
|
|||
w_string_temp = Z_Malloc(128);
|
||||
if (h == -1)
|
||||
{
|
||||
Con_DPrintf("No waypoint file (%s/maps/%s.way) found\n", com_gamedir, sv.name);
|
||||
Con_DPrintf("No waypoint file (%s/maps/%s.way) found, trying beta format..\n", com_gamedir, sv.name);
|
||||
Load_Waypoint_NZPBETA();
|
||||
return;
|
||||
}
|
||||
for (i = 0; i < MAX_WAYPOINTS; i++)
|
||||
|
@ -1727,7 +1827,6 @@ void Load_Waypoint ()
|
|||
|
||||
// what's the point of id and index being the same?
|
||||
waypoints[i].id = i;
|
||||
|
||||
VectorCopy (d, waypoints[i].origin);
|
||||
|
||||
strcpy(waypoints[i].special, W_substring (W_fgets (h), 10, 20));
|
||||
|
@ -1736,7 +1835,7 @@ void Load_Waypoint ()
|
|||
waypoints[i].open = 0;
|
||||
else
|
||||
waypoints[i].open = 1;
|
||||
|
||||
|
||||
// Note: this block makes sure that empty/invalid neighbors are always packed to the end
|
||||
// In other words, when iterating from start, first empty means rest are empty too.
|
||||
int slot = 0;
|
||||
|
@ -1771,12 +1870,12 @@ void Load_Waypoint ()
|
|||
}
|
||||
}
|
||||
Con_DPrintf("Total waypoints: %i\n", i);
|
||||
for (i = 0;i < MAX_WAYPOINTS; i++) //for sake of saving time later we are now going to save each targets array position and distace to each waypoint
|
||||
for (i = 0; i < MAX_WAYPOINTS; i++) //for sake of saving time later we are now going to save each targets array position and distace to each waypoint
|
||||
{
|
||||
for (p = 0;waypoints[i].target[p]; p++)
|
||||
for (p = 0; waypoints[i].target[p]; p++)
|
||||
{
|
||||
if (waypoints[i].target[p] < 0) break;
|
||||
|
||||
|
||||
for (s = 0; s < MAX_WAYPOINTS; s++)
|
||||
{
|
||||
if (waypoints[i].target[p] == s)
|
||||
|
@ -1786,32 +1885,32 @@ void Load_Waypoint ()
|
|||
}
|
||||
}
|
||||
}
|
||||
// Con_DPrintf("Waypoint (%i)target: %i (%i, %f), target2: %i (%i, %f), target3: %i (%i, %f), target4: %i (%i, %f), target5: %i (%i, %f), target6: %i (%i, %f), target7: %i (%i, %f), target8: %i (%i, %f)\n",
|
||||
// waypoints[i].id,
|
||||
// waypoints[i].target[0],
|
||||
// waypoints[i].target_id[0],
|
||||
// waypoints[i].dist[0],
|
||||
// waypoints[i].target[1],
|
||||
// waypoints[i].target_id[1],
|
||||
// waypoints[i].dist[1],
|
||||
// waypoints[i].target[2],
|
||||
// waypoints[i].target_id[2],
|
||||
// waypoints[i].dist[2],
|
||||
// waypoints[i].target[3],
|
||||
// waypoints[i].target_id[3],
|
||||
// waypoints[i].dist[3],
|
||||
// waypoints[i].target[4],
|
||||
// waypoints[i].target_id[4],
|
||||
// waypoints[i].dist[4],
|
||||
// waypoints[i].target[5],
|
||||
// waypoints[i].target_id[5],
|
||||
// waypoints[i].dist[5],
|
||||
// waypoints[i].target[6],
|
||||
// waypoints[i].target_id[6],
|
||||
// waypoints[i].dist[6],
|
||||
// waypoints[i].target[7],
|
||||
// waypoints[i].target_id[7],
|
||||
// waypoints[i].dist[7]);
|
||||
Con_DPrintf("Waypoint (%i)\n target: %i (%i, %f),\n target2: %i (%i, %f),\n target3: %i (%i, %f),\n target4: %i (%i, %f),\n target5: %i (%i, %f),\n target6: %i (%i, %f),\n target7: %i (%i, %f),\n target8: %i (%i, %f)\n",
|
||||
waypoints[i].id,
|
||||
waypoints[i].target[0],
|
||||
waypoints[i].target_id[0],
|
||||
waypoints[i].dist[0],
|
||||
waypoints[i].target[1],
|
||||
waypoints[i].target_id[1],
|
||||
waypoints[i].dist[1],
|
||||
waypoints[i].target[2],
|
||||
waypoints[i].target_id[2],
|
||||
waypoints[i].dist[2],
|
||||
waypoints[i].target[3],
|
||||
waypoints[i].target_id[3],
|
||||
waypoints[i].dist[3],
|
||||
waypoints[i].target[4],
|
||||
waypoints[i].target_id[4],
|
||||
waypoints[i].dist[4],
|
||||
waypoints[i].target[5],
|
||||
waypoints[i].target_id[5],
|
||||
waypoints[i].dist[5],
|
||||
waypoints[i].target[6],
|
||||
waypoints[i].target_id[6],
|
||||
waypoints[i].dist[6],
|
||||
waypoints[i].target[7],
|
||||
waypoints[i].target_id[7],
|
||||
waypoints[i].dist[7]);
|
||||
}
|
||||
W_fclose(h);
|
||||
//Z_Free (w_string_temp);
|
||||
|
|
Loading…
Reference in a new issue