diff --git a/docs/rh-log.txt b/docs/rh-log.txt index e3a07711f..193bb88a3 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,11 @@ +July 9, 2006 (Changes by Graf Zahl) +- Fixed: The defaultbind command still treated the bindings as char pointers and + as a result didn't work. +- Added SpawnSpotFacing ACS function which is the same as SpawnSpot but it uses + the map spot's angle. +- Added ThingCountName ACS function which is the same as ThingCount but it takes + an actor's type name instead of a spawn ID. + July 9, 2006 - Fixed: If the sector behind a seg was closed, but it was closed between the ceiling and floor of the front sector, the renderer did not add it to the diff --git a/src/c_bind.cpp b/src/c_bind.cpp index 1cc38145a..0234bab8d 100644 --- a/src/c_bind.cpp +++ b/src/c_bind.cpp @@ -368,19 +368,19 @@ CCMD (defaultbind) Printf ("Unknown key \"%s\"\n", argv[1]); return; } - if (Bindings[key] != NULL) + if (!Bindings[key].IsEmpty()) { // This key is already bound. return; } for (int i = 0; i < NUM_KEYS; ++i) { - if (Bindings[i] != NULL && stricmp (Bindings[i], argv[2]) == 0) + if (!Bindings[i].IsEmpty() && stricmp (Bindings[i], argv[2]) == 0) { // This command is already bound to a key. return; } } // It is safe to do the bind, so do it. - Bindings[key] = copystring (argv[2]); + Bindings[key] = argv[2]; } } diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 9afa41b27..96a87cdd3 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -1675,7 +1675,7 @@ int DLevelScript::Random (int min, int max) return min + pr_acs(max - min + 1); } -int DLevelScript::ThingCount (int type, int tid) +int DLevelScript::ThingCount (int type, int stringid, int tid) { AActor *actor; const PClass *kind; @@ -1691,6 +1691,17 @@ int DLevelScript::ThingCount (int type, int tid) if (kind == NULL) return 0; } + else if (stringid >= 0) + { + const char *type_name = FBehavior::StaticLookupString (stringid); + if (type_name == NULL) + return 0; + + kind = PClass::FindClass (type_name); + if (kind == NULL) + return 0; + + } else { kind = NULL; @@ -1861,6 +1872,19 @@ int DLevelScript::DoSpawnSpot (int type, int spot, int tid, int angle) return spawned; } +int DLevelScript::DoSpawnSpotFacing (int type, int spot, int tid) +{ + FActorIterator iterator (spot); + AActor *aspot; + int spawned = 0; + + while ( (aspot = iterator.Next ()) ) + { + spawned = DoSpawn (type, aspot->x, aspot->y, aspot->z, tid, aspot->angle); + } + return spawned; +} + void DLevelScript::DoFadeTo (int r, int g, int b, int a, fixed_t time) { DoFadeRange (0, 0, 0, -1, r, g, b, a, time); @@ -3119,15 +3143,20 @@ int DLevelScript::RunScript () break; case PCD_THINGCOUNT: - STACK(2) = ThingCount (STACK(2), STACK(1)); + STACK(2) = ThingCount (STACK(2), -1, STACK(1)); sp--; break; case PCD_THINGCOUNTDIRECT: - PushToStack (ThingCount (pc[0], pc[1])); + PushToStack (ThingCount (pc[0], -1, pc[1])); pc += 2; break; + case PCD_THINGCOUNTNAME: + STACK(2) = ThingCount (-1, STACK(2), STACK(1)); + sp--; + break; + case PCD_TAGWAIT: state = SCRIPT_TagWait; statedata = STACK(1); @@ -3834,6 +3863,11 @@ int DLevelScript::RunScript () pc += 4; break; + case PCD_SPAWNSPOTFACING: + STACK(3) = DoSpawnSpotFacing (STACK(3), STACK(2), STACK(1)); + sp -= 2; + break; + case PCD_CLEARINVENTORY: ClearInventory (activator); break; diff --git a/src/p_acs.h b/src/p_acs.h index 72146d22d..97212dbc2 100644 --- a/src/p_acs.h +++ b/src/p_acs.h @@ -491,6 +491,8 @@ public: PCD_GIVEACTORINVENTORY, PCD_TAKEACTORINVENTORY, PCD_CHECKACTORINVENTORY, + PCD_THINGCOUNTNAME, + PCD_SPAWNSPOTFACING, PCODE_COMMAND_COUNT }; @@ -590,12 +592,13 @@ protected: void PutLast (); void PutFirst (); static int Random (int min, int max); - static int ThingCount (int type, int tid); + static int ThingCount (int type, int stringid, int tid); static void ChangeFlat (int tag, int name, bool floorOrCeiling); static int CountPlayers (); static void SetLineTexture (int lineid, int side, int position, int name); static int DoSpawn (int type, fixed_t x, fixed_t y, fixed_t z, int tid, int angle); static int DoSpawnSpot (int type, int spot, int tid, int angle); + static int DoSpawnSpotFacing (int type, int spot, int tid); void DoFadeTo (int r, int g, int b, int a, fixed_t time); void DoFadeRange (int r1, int g1, int b1, int a1, diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 0e4ad70c6..70c1c3b84 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -785,6 +785,8 @@ AInventory *AActor::FindInventory (const PClass *type) const { AInventory *item; + if (type == NULL) return NULL; + assert (type->ActorInfo != NULL); for (item = Inventory; item != NULL; item = item->Inventory) {