// Read from disk file void ACEND_LoadNodes(void) { fileHandle_t file; int i, j; char filename[MAX_QPATH]; int version; char mapname[MAX_QPATH]; trap_Cvar_VariableStringBuffer("mapname", mapname, sizeof(mapname)); Com_sprintf(filename, sizeof(filename), "nav/%s.nod", mapname); trap_FS_FOpenFile(filename, &file, FS_READ); if(!file) { // Create item table G_Printf("ACE: No node file '%s' found\n", filename); //ACEIT_BuildItemNodeTable(qfalse); //G_Printf("done.\n"); return; } // determin version trap_FS_Read(&version, sizeof(int), file); // read version if(version == 1) { G_Printf("ACE: Loading node table '%s'...\n", filename); trap_FS_Read(&numNodes, sizeof(int), file); // read count trap_FS_Read(&nodes, sizeof(node_t) * numNodes, file); for(i = 0; i < numNodes; i++) for(j = 0; j < numNodes; j++) trap_FS_Read(&path_table[i][j], sizeof(short int), file); // write count if(ace_showNodes.integer) { for(i = 0; i < numNodes; i++) ACEND_ShowNode(i); } } else { // Create item table G_Printf("ACE: '%s' has wrong version %i\n", filename, version); //ACEIT_BuildItemNodeTable(qfalse); //G_Printf("done.\n"); } trap_FS_FCloseFile(file); G_Printf("done.\n"); G_Printf("%i nodes loaded\n", numNodes); ACEIT_BuildItemNodeTable(qtrue); }
/////////////////////////////////////////////////////////////////////// // Add a node of type ? /////////////////////////////////////////////////////////////////////// int ACEND_AddNode(edict_t *self, int type) { vec3_t v1,v2; // Block if we exceed maximum if (numnodes + 1 > MAX_NODES) return false; // Set location VectorCopy(self->s.origin,nodes[numnodes].origin); // Set type nodes[numnodes].type = type; ///////////////////////////////////////////////////// // ITEMS // Move the z location up just a bit. if(type == NODE_ITEM) { nodes[numnodes].origin[2] += 16; numitemnodes++; } // Teleporters if(type == NODE_TELEPORTER) { // Up 32 nodes[numnodes].origin[2] += 32; } if(type == NODE_LADDER) { nodes[numnodes].type = NODE_LADDER; if(debug_mode) { debug_printf("Node added %d type: Ladder\n",numnodes); ACEND_ShowNode(numnodes); } numnodes++; return numnodes-1; // return the node added } // For platforms drop two nodes one at top, one at bottom if(type == NODE_PLATFORM) { VectorCopy(self->maxs,v1); VectorCopy(self->mins,v2); // To get the center nodes[numnodes].origin[0] = (v1[0] - v2[0]) / 2 + v2[0]; nodes[numnodes].origin[1] = (v1[1] - v2[1]) / 2 + v2[1]; nodes[numnodes].origin[2] = self->maxs[2]; if(debug_mode) ACEND_ShowNode(numnodes); numnodes++; nodes[numnodes].origin[0] = nodes[numnodes-1].origin[0]; nodes[numnodes].origin[1] = nodes[numnodes-1].origin[1]; nodes[numnodes].origin[2] = self->mins[2]+64; nodes[numnodes].type = NODE_PLATFORM; // Add a link ACEND_UpdateNodeEdge(numnodes,numnodes-1); if(debug_mode) { debug_printf("Node added %d type: Platform\n",numnodes); ACEND_ShowNode(numnodes); } numnodes++; return numnodes -1; } if(debug_mode) { if(nodes[numnodes].type == NODE_MOVE) debug_printf("Node added %d type: Move\n",numnodes); else if(nodes[numnodes].type == NODE_TELEPORTER) debug_printf("Node added %d type: Teleporter\n",numnodes); else if(nodes[numnodes].type == NODE_ITEM) debug_printf("Node added %d type: Item\n",numnodes); else if(nodes[numnodes].type == NODE_WATER) debug_printf("Node added %d type: Water\n",numnodes); else if(nodes[numnodes].type == NODE_GRAPPLE) debug_printf("Node added %d type: Grapple\n",numnodes); ACEND_ShowNode(numnodes); } numnodes++; return numnodes-1; // return the node added }
int ACEND_AddNode(gentity_t * self, int type) { vec3_t v, v2; const char *entityName; // block if we exceed maximum if(numNodes >= MAX_NODES) return INVALID; #if 0 // it's better when bots do not create any path nodes .. if(self->r.svFlags & SVF_BOT) return INVALID; #endif if(self->name) { entityName = self->name; } else { entityName = self->classname; } // set location if(self->client) VectorCopy(self->client->ps.origin, nodes[numNodes].origin); else VectorCopy(self->s.origin, nodes[numNodes].origin); // set type nodes[numNodes].type = type; // move the z location up just a bit for items if(type == NODE_ITEM) { //nodes[numNodes].origin[2] += 16; } // teleporters /* else if(type == NODE_TARGET_TELEPORT) { nodes[numNodes].origin[2] += 32; } */ else if(type == NODE_TRIGGER_TELEPORT) { VectorAdd(self->r.absmin, self->r.absmax, v); VectorScale(v, 0.5, v); VectorCopy(v, nodes[numNodes].origin); } else if(type == NODE_JUMPPAD) { VectorAdd(self->r.absmin, self->r.absmax, v); VectorScale(v, 0.5, v); // add jumppad target offset VectorNormalize2(self->s.origin2, v2); VectorMA(v, 32, v2, v); VectorCopy(v, nodes[numNodes].origin); } /* // for platforms drop two nodes one at top, one at bottom if(type == NODE_PLATFORM) { VectorCopy(self->r.maxs, v1); VectorCopy(self->r.mins, v2); // to get the center nodes[numNodes].origin[0] = (v1[0] - v2[0]) / 2 + v2[0]; nodes[numNodes].origin[1] = (v1[1] - v2[1]) / 2 + v2[1]; nodes[numNodes].origin[2] = self->r.maxs[2]; if(ace_debug.integer) ACEND_ShowNode(numNodes); numNodes++; nodes[numNodes].origin[0] = nodes[numNodes - 1].origin[0]; nodes[numNodes].origin[1] = nodes[numNodes - 1].origin[1]; nodes[numNodes].origin[2] = self->r.mins[2] + 64; nodes[numNodes].type = NODE_PLATFORM; // add a link ACEND_UpdateNodeEdge(numNodes, numNodes - 1); if(ace_debug.integer) { debug_printf("Node %d added for entity %s type: Platform\n", numNodes, entityName); ACEND_ShowNode(numNodes); } numNodes++; return numNodes - 1; } */ SnapVector(nodes[numNodes].origin); if(ace_debug.integer) { G_Printf("node %d added for entity %s type: %s pos: %f %f %f\n", numNodes, entityName, ACEND_NodeTypeToString(nodes[numNodes].type), nodes[numNodes].origin[0], nodes[numNodes].origin[1], nodes[numNodes].origin[2]); ACEND_ShowNode(numNodes); } // add a link //ACEND_UpdateNodeEdge(numNodes, numNodes - 1); numNodes++; return numNodes - 1; // return the node added }