#include <Assert.h>#include <Windows.h>#include "BaseType.h"#include "Errorlog.h"#include "Vec3d.h"#include "System.h"#include "World.h"#include "Ram.h"Go to the source code of this file.
|
|
|
|
|
Definition at line 55 of file ENTITIES.H. |
|
|
|
|
|
|
|
|
|
|
|
Definition at line 43 of file ENTITIES.H.
00044 {
00045 TYPE_INT,
00046 TYPE_FLOAT,
00047 TYPE_COLOR,
00048 TYPE_POINT,
00049 TYPE_STRING,
00050 TYPE_MODEL,
00051 TYPE_STRUCT,
00052 TYPE_PTR,
00053 } geEntity_ClassType;
|
|
|
Definition at line 96 of file Entities.c. References GE_FALSE, GE_TRUE, geBoolean, geEntity_EntitySetGetNextEntity(), GBSP_BSPData::GFXEntData, GWorld, InsertEntityInClassList(), LoadEntitySet(), NULL, geWorld::NumEntClassSets, and GBSP_BSPData::NumGFXEntData. Referenced by geWorld_Create().
00097 {
00098 GBSP_BSPData *BSP;
00099 geEntity_EntitySet *EntitySet;
00100 geEntity *Entity;
00101
00102 assert(World != NULL);
00103
00104 GWorld = World;
00105
00106 World->NumEntClassSets = 0;
00107
00108 if ( ! World->CurrentBSP )
00109 return GE_TRUE;
00110
00111 BSP = &(World->CurrentBSP->BSPData);
00112
00113 if (BSP->NumGFXEntData == 0)
00114 return GE_TRUE; // Nothing to do...
00115
00116 EntitySet = LoadEntitySet(BSP->GFXEntData, BSP->NumGFXEntData);
00117
00118 if (!EntitySet)
00119 return GE_FALSE;
00120
00121 // Insert default set...
00122 World->EntClassSets[0].ClassName = NULL;
00123 World->EntClassSets[0].Set = EntitySet;
00124 World->NumEntClassSets++;
00125
00126 // Build class sets
00127 Entity = NULL;
00128 while (1)
00129 {
00130 Entity = geEntity_EntitySetGetNextEntity(EntitySet, Entity);
00131
00132 if (!Entity)
00133 break; // Done
00134
00135 InsertEntityInClassList(World, Entity);
00136 }
00137
00138 return GE_TRUE;
00139 }
|
|
|
Definition at line 145 of file Entities.c. References geWorld::EntClassSets, geEntity_EntitySetDestroy(), int32, geWorld::NumEntClassSets, and geWorld_EntClassSet::Set. Referenced by geWorld_Free().
00146 {
00147 int32 i;
00148
00149 assert(World);
00150
00151 for (i=0; i< World->NumEntClassSets; i++)
00152 geEntity_EntitySetDestroy(World->EntClassSets[i].Set);
00153 }
|
|
||||||||||||
|
Definition at line 250 of file Entities.c. References geEntity::Epairs, GE_TRUE, geBoolean, geEntity_Epair::Next, and NULL. Referenced by geEntity_EntitySetLoadEntities().
00251 {
00252 geEntity_Epair *Ep;
00253
00254 assert(Entity);
00255 assert(Epair);
00256
00257 assert(Epair->Next == NULL); // Make sure this is a fresh one (ahh yahh)
00258
00259 if (!Entity->Epairs)
00260 {
00261 Entity->Epairs = Epair;
00262 return GE_TRUE;
00263 }
00264
00265 // Jump to end of list
00266 for (Ep = Entity->Epairs; Ep->Next; Ep = Ep->Next);
00267
00268 Ep->Next = Epair;
00269
00270 return GE_TRUE;
00271 }
|
|
||||||||||||
|
Definition at line 405 of file Entities.c. References geEntity_Class::Fields, geEntity_Class::FieldSize, GE_TRUE, geBoolean, geEntity_Field::Next, geEntity_Field::TypeClass, and geEntity_Class::TypeSize. Referenced by BuildClassTypes().
|
|
||||||||||||||||
|
Definition at line 362 of file Entities.c. References CopyString(), GE_RAM_ALLOCATE_STRUCT, geEntity_Class::Name, NULL, geEntity_Class::Type, and geEntity_Class::TypeSize. Referenced by BuildClassTypes().
00363 {
00364 geEntity_Class *Class;
00365
00366 Class = GE_RAM_ALLOCATE_STRUCT(geEntity_Class);
00367
00368 if (!Class)
00369 return NULL;
00370
00371 memset(Class, 0, sizeof(geEntity_Class));
00372
00373 Class->Type = Type;
00374
00375 if (Name)
00376 Class->Name = CopyString(Name);
00377
00378 Class->TypeSize = TypeSize;
00379
00380 return Class;
00381 }
|
|
|
Definition at line 386 of file Entities.c. References geEntity_Class::Fields, geEntity_FieldDestroy(), geRam_Free, geEntity_Class::Name, and geEntity_Field::Next. Referenced by BuildClassTypes(), and geEntity_EntitySetDestroy().
00387 {
00388 geEntity_Field *Field, *NextField;
00389 assert(Class);
00390
00391 for (Field = Class->Fields; Field; Field = NextField )
00392 {
00393 NextField = Field->Next;
00394 geEntity_FieldDestroy(Field);
00395 }
00396 if (Class->Name)
00397 geRam_Free(Class->Name);
00398
00399 geRam_Free(Class);
00400 }
|
|
||||||||||||
|
Definition at line 423 of file Entities.c. References geEntity_Class::Fields, geEntity_Field::Name, geEntity_Field::Next, and NULL. Referenced by ParseClassUserData().
00424 {
00425 geEntity_Field *Field;
00426
00427 assert(Class);
00428
00429 for (Field = Class->Fields; Field; Field = Field->Next)
00430 {
00431 if (!stricmp(Field->Name, Name))
00432 return Field;
00433
00434 }
00435
00436 return NULL;
00437 }
|
|
|
Definition at line 175 of file Entities.c. References geRam_Allocate, and NULL. Referenced by geEntity_EntitySetLoadEntities().
00176 {
00177 geEntity *Entity;
00178
00179 Entity = geRam_Allocate(sizeof(geEntity));
00180
00181 if (!Entity)
00182 return NULL;
00183
00184 memset(Entity, 0, sizeof(geEntity));
00185
00186 return Entity;
00187 }
|
|
|
Definition at line 193 of file Entities.c. References geEntity::Epairs, geEntity_EpairDestroy(), geRam_Free, geEntity_Epair::Next, and geEntity::UserData. Referenced by geEntity_EntitySetDestroy().
00194 {
00195 geEntity_Epair *Epair, *Next;
00196
00197 assert(Entity);
00198
00199 for (Epair = Entity->Epairs; Epair; Epair = Next)
00200 {
00201 Next = Epair->Next;
00202
00203 geEntity_EpairDestroy(Epair);
00204 }
00205
00206 if (Entity->UserData)
00207 geRam_Free(Entity->UserData);
00208
00209 geRam_Free(Entity);
00210 }
|
|
||||||||||||
|
Definition at line 635 of file Entities.c. References geEntity_EntitySet::Classes, GE_TRUE, geBoolean, geEntity_Class::Next, and NULL. Referenced by BuildClassTypes().
|
|
||||||||||||
|
Definition at line 553 of file Entities.c. References geEntity_EntitySet::Current, geEntity_EntitySet::Entity, GE_FALSE, GE_TRUE, geBoolean, geEntity_EntitySetCreate(), geEntity_EntitySet::Next, and NULL. Referenced by geEntity_EntitySetLoadEntities(), and InsertEntityInClassList().
00554 {
00555 geEntity_EntitySet *NewSet, *Set;
00556
00557 assert(EntitySet);
00558 assert(Entity);
00559
00560 // If no entities in list, just make this one the first
00561 if (!EntitySet->Entity)
00562 {
00563 assert(EntitySet->Next == NULL);
00564 assert(EntitySet->Current == NULL);
00565
00566 EntitySet->Entity = Entity;
00567 return GE_TRUE;
00568 }
00569
00570 NewSet = geEntity_EntitySetCreate();
00571
00572 if (!NewSet)
00573 return GE_FALSE;
00574
00575 // Store the entity
00576 NewSet->Entity = Entity;
00577
00578 // Jump to end of list (we allways want them to work on the first set in the list...)
00579 for (Set = EntitySet; Set->Next; Set = Set->Next);
00580
00581 // Add the newset
00582 Set->Next = NewSet;
00583 return GE_TRUE;
00584 }
|
|
|
Definition at line 442 of file Entities.c. References geRam_Allocate, and NULL. Referenced by geEntity_EntitySetAddEntity(), InsertEntityInClassList(), and LoadEntitySet().
00443 {
00444 geEntity_EntitySet *EntitySet;
00445
00446 EntitySet = geRam_Allocate(sizeof(geEntity_EntitySet));
00447
00448 if (!EntitySet)
00449 return NULL;
00450
00451 memset(EntitySet, 0, sizeof(geEntity_EntitySet));
00452
00453 return EntitySet;
00454 }
|
|
|
Definition at line 460 of file Entities.c. References geEntity_EntitySet::Classes, geEntity_EntitySet::Entity, geEntity_ClassDestroy(), geEntity_Destroy(), geRam_Free, geEntity_EntitySet::Next, geEntity_Class::Next, and geEntity_EntitySet::OwnsEntities. Referenced by Ent_WorldShutdown(), and LoadEntitySet().
00461 {
00462 geEntity_EntitySet *Set, *Next;
00463 geEntity_Class *Class, *NextClass;
00464
00465 assert(EntitySet);
00466
00467 if (EntitySet->OwnsEntities) // Free stuff if we created all this stuff
00468 {
00469 for (Class = EntitySet->Classes; Class; Class = NextClass)
00470 {
00471 NextClass = Class->Next;
00472
00473 geEntity_ClassDestroy(Class);
00474 }
00475
00476 for (Set = EntitySet; Set; Set = Next)
00477 {
00478 Next = Set->Next;
00479 if (Set->Entity)
00480 geEntity_Destroy(Set->Entity);
00481 }
00482 }
00483
00484 // Finclaly destroy the sets themselves...
00485 for (Set = EntitySet; Set; Set = Next)
00486 {
00487 Next = Set->Next;
00488
00489 geRam_Free(Set);
00490 }
00491 }
|
|
||||||||||||
|
Definition at line 496 of file Entities.c. References geEntity_EntitySet::Classes, geEntity_Class::Name, geEntity_Class::Next, and NULL. Referenced by BuildClassTypes(), and ParseClassData().
00497 {
00498 geEntity_Class *Class;
00499
00500 assert(Set);
00501
00502 for (Class = Set->Classes; Class; Class = Class->Next)
00503 {
00504 if (!stricmp(Class->Name, Name))
00505 return Class;
00506 }
00507
00508 return NULL; // Not found!!!
00509 }
|
|
||||||||||||
|
Definition at line 528 of file Entities.c. References geEntity_EntitySet::Entity, geEntity_GetStringForKey(), geEntity_EntitySet::Next, and NULL. Referenced by ParseClassUserData().
00529 {
00530 const char *EntName;
00531 geEntity_EntitySet *Set;
00532
00533 assert(EntitySet);
00534 assert(Name);
00535
00536 for (Set = EntitySet; Set; Set = Set->Next)
00537 {
00538 EntName = geEntity_GetStringForKey(Set->Entity, "%Name%");
00539
00540 if (!EntName)
00541 continue;
00542
00543 if (!stricmp(Name, EntName))
00544 return Set->Entity;
00545 }
00546
00547 return NULL;
00548 }
|
|
||||||||||||
|
Definition at line 589 of file Entities.c.
00590 {
00591 geEntity_EntitySet *Set, *NextSet;
00592
00593 assert(EntitySet);
00594
00595 if (!Entity)
00596 {
00597 EntitySet->Current = EntitySet;
00598 return EntitySet->Entity;
00599 }
00600
00601 assert(EntitySet->Current);
00602
00603 // Search is easy if this was the last entity we returned
00604 if (EntitySet->Current->Entity == Entity)
00605 {
00606 NextSet = EntitySet->Current->Next;
00607
00608 if (!NextSet)
00609 return NULL; // No more in the list
00610
00611 EntitySet->Current = NextSet;
00612 return NextSet->Entity;
00613 }
00614
00615 // Must do a search now, that'll teach'em to jump around...
00616 for (Set = EntitySet; Set; Set = Set->Next)
00617 {
00618 assert(Set->Entity);
00619
00620 if (Set->Entity == Entity)
00621 {
00622 NextSet = Set->Next;
00623
00624 EntitySet->Current = NextSet;
00625 return NextSet->Entity;
00626 }
00627 }
00628
00629 return NULL;
00630 }
|
|
|
Definition at line 293 of file Entities.c. References geRam_Allocate, and NULL. Referenced by geEntity_EntitySetLoadEntities().
00294 {
00295 geEntity_Epair *Epair;
00296
00297 Epair = geRam_Allocate(sizeof(geEntity_Epair));
00298
00299 if (!Epair)
00300 return NULL;
00301
00302 memset(Epair, 0, sizeof(geEntity_Epair));
00303
00304 return Epair;
00305 }
|
|
|
Definition at line 310 of file Entities.c. References geRam_Free, geEntity_Epair::Key, and geEntity_Epair::Value. Referenced by geEntity_Destroy().
00311 {
00312 assert(Epair);
00313
00314 if (Epair->Key)
00315 geRam_Free(Epair->Key);
00316
00317 if (Epair->Value)
00318 geRam_Free(Epair->Value);
00319
00320 geRam_Free(Epair);
00321 }
|
|
||||||||||||||||
|
Definition at line 326 of file Entities.c. References CopyString(), GE_RAM_ALLOCATE_STRUCT, geEntity_Field::Name, NULL, geEntity_Field::Offset, and geEntity_Field::TypeClass. Referenced by BuildClassTypes().
00327 {
00328 geEntity_Field *Field;
00329
00330 Field = GE_RAM_ALLOCATE_STRUCT(geEntity_Field);
00331
00332 if (!Field)
00333 return NULL;
00334
00335 memset(Field, 0, sizeof(geEntity_Field));
00336
00337 if (Name)
00338 Field->Name = CopyString(Name);
00339
00340 Field->Offset = Offset;
00341 Field->TypeClass = TypeClass;
00342
00343 return Field;
00344 }
|
|
|
Definition at line 349 of file Entities.c. References geRam_Free, and geEntity_Field::Name. Referenced by geEntity_ClassDestroy().
00350 {
00351 assert(Field);
00352
00353 if (Field->Name)
00354 geRam_Free(Field->Name);
00355
00356 geRam_Free(Field);
00357 }
|
|
||||||||||||||||
|
Definition at line 225 of file Entities.c. References geEntity::Epairs, GE_FALSE, GE_TRUE, geBoolean, int32, geEntity_Epair::Key, geEntity_Epair::Next, and geEntity_Epair::Value. Referenced by ParseClassUserData().
00226 {
00227 geEntity_Epair *Epair;
00228 int32 Value;
00229
00230 for (Epair = Entity->Epairs; Epair; Epair = Epair->Next)
00231 {
00232 if (!stricmp(Epair->Key, Key))
00233 {
00234 if (Epair->Value[0] == '*')
00235 sscanf(Epair->Value+1, "%d", &Value);
00236 else
00237 sscanf(Epair->Value, "%d", &Value);
00238
00239 *ModelNum = (int32)Value;
00240 return GE_TRUE;
00241 }
00242 }
00243 return GE_FALSE; // not found !
00244
00245 }
|
|
||||||||||||||||
|
Definition at line 511 of file Entities.c.
00512 {
00513 const char * EntName;
00514 int Length;
00515
00516 assert(Entity);
00517 assert(Buff);
00518
00519 EntName = geEntity_GetStringForKey(Entity, "%Name%");
00520 assert(EntName);
00521 Length = strlen(EntName) + 1;
00522 memcpy(Buff, EntName, min(Length, MaxLen));
00523 }
|
|
||||||||||||
|
Definition at line 276 of file Entities.c. References geEntity::Epairs, geEntity_Epair::Key, geEntity_Epair::Next, NULL, and geEntity_Epair::Value. Referenced by BuildClassTypes(), geEntity_EntitySetFindEntityByName(), geEntity_GetName(), and ParseClassData().
|
|
||||||||||||
|
Definition at line 1068 of file Entities.c. References geVFile_MemoryContext::Data, geVFile_MemoryContext::DataLength, FALSE, GE_TRUE, GE_VFILE_OPEN_READONLY, GE_VFILE_TYPE_MEMORY, geEntity_EntitySetBuildClasses(), geEntity_EntitySetCreate(), geEntity_EntitySetDestroy(), geEntity_EntitySetLoadEntities(), geVFile_Close(), geVFile_OpenNewSystem(), NULL, and geEntity_EntitySet::OwnsEntities. Referenced by Ent_WorldInit().
01069 {
01070 geEntity_EntitySet *EntitySet;
01071 geVFile_MemoryContext Context;
01072 geVFile *MemFile;
01073
01074 // Default some NULLS here
01075 EntitySet = NULL;
01076 MemFile = NULL;
01077
01078 // Setup the context for the memfile
01079 Context.Data = (void*)EntityData;
01080 Context.DataLength = EntityDataSize;
01081
01082 MemFile = geVFile_OpenNewSystem(NULL, GE_VFILE_TYPE_MEMORY, NULL, &Context, GE_VFILE_OPEN_READONLY);
01083
01084 if (!MemFile)
01085 return FALSE;
01086
01087 // Create the entityset
01088 EntitySet = geEntity_EntitySetCreate();
01089
01090 if (!EntitySet) // Out of memory!!
01091 goto ExitWithError;
01092
01093 EntitySet->OwnsEntities = GE_TRUE; // So this set will be the one to free everything...
01094
01095 if (!geEntity_EntitySetLoadEntities(EntitySet, MemFile))
01096 goto ExitWithError;
01097
01098 geVFile_Close(MemFile);
01099 MemFile = NULL;
01100
01101 if (!geEntity_EntitySetBuildClasses(EntitySet))
01102 goto ExitWithError;
01103
01104 return EntitySet;
01105
01106 // ** ERROR **
01107 ExitWithError:
01108 {
01109 if (EntitySet)
01110 geEntity_EntitySetDestroy(EntitySet);
01111
01112 if (MemFile)
01113 geVFile_Close(MemFile);
01114
01115 return NULL;
01116 }
01117 }
|
1.3.2