00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "../game/q_shared.h"
00024 #include "../bspc/l_log.h"
00025 #include "../bspc/l_qfiles.h"
00026 #include "../botlib/l_memory.h"
00027 #include "../botlib/l_script.h"
00028 #include "../botlib/l_precomp.h"
00029 #include "../botlib/l_struct.h"
00030 #include "../botlib/aasfile.h"
00031 #include "../game/botlib.h"
00032 #include "../game/be_aas.h"
00033 #include "../botlib/be_aas_def.h"
00034 #include "../qcommon/cm_public.h"
00035
00036
00037
00038 extern botlib_import_t botimport;
00039 extern qboolean capsule_collision;
00040
00041 botlib_import_t botimport;
00042 clipHandle_t worldmodel;
00043
00044 void Error (char *error, ...);
00045
00046
00047
00048
00049
00050
00051
00052 void AAS_Error(char *fmt, ...)
00053 {
00054 va_list argptr;
00055 char text[1024];
00056
00057 va_start(argptr, fmt);
00058 vsprintf(text, fmt, argptr);
00059 va_end(argptr);
00060
00061 Error(text);
00062 }
00063
00064
00065
00066
00067
00068
00069 int Sys_MilliSeconds(void)
00070 {
00071 return clock() * 1000 / CLOCKS_PER_SEC;
00072 }
00073
00074
00075
00076
00077
00078
00079 void AAS_DebugLine(vec3_t start, vec3_t end, int color)
00080 {
00081 }
00082
00083
00084
00085
00086
00087
00088 void AAS_ClearShownDebugLines(void)
00089 {
00090 }
00091
00092
00093
00094
00095
00096
00097 char *BotImport_BSPEntityData(void)
00098 {
00099 return CM_EntityString();
00100 }
00101
00102
00103
00104
00105
00106
00107 void BotImport_Trace(bsp_trace_t *bsptrace, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int passent, int contentmask)
00108 {
00109 trace_t result;
00110
00111 CM_BoxTrace(&result, start, end, mins, maxs, worldmodel, contentmask, capsule_collision);
00112
00113 bsptrace->allsolid = result.allsolid;
00114 bsptrace->contents = result.contents;
00115 VectorCopy(result.endpos, bsptrace->endpos);
00116 bsptrace->ent = result.entityNum;
00117 bsptrace->fraction = result.fraction;
00118 bsptrace->exp_dist = 0;
00119 bsptrace->plane.dist = result.plane.dist;
00120 VectorCopy(result.plane.normal, bsptrace->plane.normal);
00121 bsptrace->plane.signbits = result.plane.signbits;
00122 bsptrace->plane.type = result.plane.type;
00123 bsptrace->sidenum = 0;
00124 bsptrace->startsolid = result.startsolid;
00125 bsptrace->surface.flags = result.surfaceFlags;
00126 }
00127
00128
00129
00130
00131
00132
00133 int BotImport_PointContents(vec3_t p)
00134 {
00135 return CM_PointContents(p, worldmodel);
00136 }
00137
00138
00139
00140
00141
00142
00143 void *BotImport_GetMemory(int size)
00144 {
00145 return GetMemory(size);
00146 }
00147
00148
00149
00150
00151
00152
00153 void BotImport_Print(int type, char *fmt, ...)
00154 {
00155 va_list argptr;
00156 char buf[1024];
00157
00158 va_start(argptr, fmt);
00159 vsprintf(buf, fmt, argptr);
00160 printf(buf);
00161 if (buf[0] != '\r') Log_Write(buf);
00162 va_end(argptr);
00163 }
00164
00165
00166
00167
00168
00169
00170 void BotImport_BSPModelMinsMaxsOrigin(int modelnum, vec3_t angles, vec3_t outmins, vec3_t outmaxs, vec3_t origin)
00171 {
00172 clipHandle_t h;
00173 vec3_t mins, maxs;
00174 float max;
00175 int i;
00176
00177 h = CM_InlineModel(modelnum);
00178 CM_ModelBounds(h, mins, maxs);
00179
00180 if ((angles[0] || angles[1] || angles[2]))
00181 {
00182
00183 max = RadiusFromBounds(mins, maxs);
00184 for (i = 0; i < 3; i++)
00185 {
00186 mins[i] = (mins[i] + maxs[i]) * 0.5 - max;
00187 maxs[i] = (mins[i] + maxs[i]) * 0.5 + max;
00188 }
00189 }
00190 if (outmins) VectorCopy(mins, outmins);
00191 if (outmaxs) VectorCopy(maxs, outmaxs);
00192 if (origin) VectorClear(origin);
00193 }
00194
00195
00196
00197
00198
00199
00200 void Com_DPrintf(char *fmt, ...)
00201 {
00202 va_list argptr;
00203 char buf[1024];
00204
00205 va_start(argptr, fmt);
00206 vsprintf(buf, fmt, argptr);
00207 printf(buf);
00208 if (buf[0] != '\r') Log_Write(buf);
00209 va_end(argptr);
00210 }
00211
00212
00213
00214
00215
00216
00217 int COM_Compress( char *data_p ) {
00218 return strlen(data_p);
00219 }
00220
00221
00222
00223
00224
00225
00226 void Com_Memset (void* dest, const int val, const size_t count) {
00227 memset(dest, val, count);
00228 }
00229
00230
00231
00232
00233
00234
00235 void Com_Memcpy (void* dest, const void* src, const size_t count) {
00236 memcpy(dest, src, count);
00237 }
00238
00239
00240
00241
00242
00243
00244 void AAS_InitBotImport(void)
00245 {
00246 botimport.BSPEntityData = BotImport_BSPEntityData;
00247 botimport.GetMemory = BotImport_GetMemory;
00248 botimport.FreeMemory = FreeMemory;
00249 botimport.Trace = BotImport_Trace;
00250 botimport.PointContents = BotImport_PointContents;
00251 botimport.Print = BotImport_Print;
00252 botimport.BSPModelMinsMaxsOrigin = BotImport_BSPModelMinsMaxsOrigin;
00253 }
00254
00255
00256
00257
00258
00259
00260 void AAS_CalcReachAndClusters(struct quakefile_s *qf)
00261 {
00262 float time;
00263
00264 Log_Print("loading collision map...\n");
00265
00266 if (!qf->pakfile[0]) strcpy(qf->pakfile, qf->filename);
00267
00268 CM_LoadMap((char *) qf, qfalse, &aasworld.bspchecksum);
00269
00270 worldmodel = CM_InlineModel(0);
00271
00272 AAS_InitBotImport();
00273
00274 AAS_LoadBSPFile();
00275
00276 AAS_InitSettings();
00277
00278 AAS_InitAASLinkHeap();
00279
00280 AAS_InitAASLinkedEntities();
00281
00282 aasworld.reachabilitysize = 0;
00283 aasworld.numclusters = 0;
00284
00285 AAS_SetViewPortalsAsClusterPortals();
00286
00287 AAS_InitReachability();
00288 time = 0;
00289 while(AAS_ContinueInitReachability(time)) time++;
00290
00291 AAS_InitClustering();
00292 }