Skip to content

Commit 529684f

Browse files
committed
Game objects testing functions replaced with game object casting (e.g. 'bool is_car' -> 'CCar* cast_Car')
1 parent 985af75 commit 529684f

File tree

4 files changed

+61
-409
lines changed

4 files changed

+61
-409
lines changed

src/Common/Config.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
/* Scripts */
1717
#define MORE_INVENTORY_SLOTS // Adds 5 more slots CUSTOM_SLOT_1..5
1818
#define GAME_OBJECT_EXTENDED_EXPORTS // see: script_game_object*.cpp/h
19-
#define GAME_OBJECT_TESTING_EXPORTS // see: script_game_object4.cpp functions for object testing (ie. is_stalker(), is_heli())
19+
#define GAME_OBJECT_CASTING_EXPORTS // see: script_game_object4.cpp functions for object casting (ie. cast_Car(), cast_Heli())
2020
#define NAMESPACE_LEVEL_EXPORTS // see: level_script.cpp
2121

2222
/* Visual */

src/xrGame/script_game_object.h

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -787,49 +787,6 @@ class CScriptGameObject
787787
void unlock_door_for_npc();
788788
bool is_door_blocked_by_npc() const;
789789
bool is_weapon_going_to_be_strapped(CScriptGameObject const* object) const;
790-
791-
//AVO: functions for object testing
792-
#ifdef GAME_OBJECT_TESTING_EXPORTS
793-
//bool isGameObject() const;
794-
//bool isCar() const;
795-
//bool isHeli() const;
796-
//bool isHolderCustom() const;
797-
bool isEntityAlive() const;
798-
bool isInventoryItem() const;
799-
bool isInventoryOwner() const;
800-
bool isActor() const;
801-
bool isCustomMonster() const;
802-
bool isWeapon() const;
803-
//bool isMedkit() const;
804-
//bool isEatableItem() const;
805-
//bool isAntirad() const;
806-
bool isCustomOutfit() const;
807-
bool isScope() const;
808-
bool isSilencer() const;
809-
bool isGrenadeLauncher() const;
810-
bool isWeaponMagazined() const;
811-
bool isSpaceRestrictor() const;
812-
bool isStalker() const;
813-
bool isAnomaly() const;
814-
bool isMonster() const;
815-
//bool isExplosive() const;
816-
//bool isScriptZone() const;
817-
//bool isProjector() const;
818-
bool isTrader() const;
819-
bool isHudItem() const;
820-
//bool isFoodItem() const;
821-
bool isArtefact() const;
822-
bool isAmmo() const;
823-
//bool isMissile() const;
824-
//bool isPhysicsShellHolder() const;
825-
//bool isGrenade() const;
826-
//bool isBottleItem() const;
827-
//bool isTorch() const;
828-
bool isWeaponGL() const;
829-
bool isInventoryBox() const;
830-
831-
#endif // GAME_OBJECT_TESTING_EXPORTS
832-
//-AVO
833790

834791
#ifdef GAME_OBJECT_EXTENDED_EXPORTS
835792
void SetHealthEx(float hp); //AVO

src/xrGame/script_game_object4.cpp

Lines changed: 1 addition & 324 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ void CScriptGameObject::stop_particles(LPCSTR pname, LPCSTR bone)
368368
LuaMessageType::Error, "Cant stop particles, bone [%s] is not visible now", bone);
369369
}
370370

371-
#ifdef GAME_OBJECT_TESTING_EXPORTS
371+
#ifdef GAME_OBJECT_EXTENDED_EXPORTS
372372
//AVO: directly set entity health instead of going through normal health property which operates on delta
373373
void CScriptGameObject::SetHealthEx(float hp)
374374
{
@@ -378,327 +378,4 @@ void CScriptGameObject::SetHealthEx(float hp)
378378
obj->SetfHealth(hp);
379379
}
380380
//-AVO
381-
382-
// AVO: functions for testing object class
383-
// Credits: KD
384-
//#include "Car.h"
385-
//#include "helicopter.h"
386-
#include "Actor.h"
387-
#include "CustomOutfit.h"
388-
//#include "CustomZone.h"
389-
#include "ai/Monsters/BaseMonster/base_monster.h"
390-
//#include "medkit.h"
391-
//#include "antirad.h"
392-
#include "Scope.h"
393-
#include "Silencer.h"
394-
//#include "Torch.h"
395-
#include "GrenadeLauncher.h"
396-
#include "searchlight.h"
397-
//#include "WeaponAmmo.h"
398-
//#include "Grenade.h"
399-
//#include "BottleItem.h"
400-
#include "WeaponMagazinedWGrenade.h"
401-
402-
// Xottab_DUTY: commented this macro, because of substituting it
403-
/*
404-
#define TEST_OBJECT_CLASS(A, B)\
405-
bool A() const\
406-
{\
407-
auto l_tpEntity = smart_cast<B*>(&object());\
408-
if (!l_tpEntity)\
409-
return false;\
410-
return true;\
411-
}\
412-
*/
413-
414-
/*
415-
bool CScriptGameObject::isGameObject() const
416-
{
417-
auto l_tpEntity = smart_cast<CGameObject*>(&object());
418-
if (!l_tpEntity) return false;
419-
return true;
420-
}
421-
*/
422-
423-
/*
424-
bool CScriptGameObject::isCar() const
425-
{
426-
auto l_tpEntity = smart_cast<CCar*>(&object());
427-
if (!l_tpEntity) return false;
428-
return true;
429-
}
430-
*/
431-
432-
/*
433-
bool CScriptGameObject::isHeli() const
434-
{
435-
auto l_tpEntity = smart_cast<CHelicopter*>(&object());
436-
if (!l_tpEntity) return false;
437-
return true;
438-
}
439-
*/
440-
441-
/*
442-
bool CScriptGameObject::isHolderCustom() const
443-
{
444-
auto l_tpEntity = smart_cast<CHolderCustom*>(&object());
445-
if (!l_tpEntity) return false;
446-
return true;
447-
}
448-
*/
449-
450-
bool CScriptGameObject::isEntityAlive() const
451-
{
452-
auto l_tpEntity = smart_cast<CEntityAlive*>(&object());
453-
if (!l_tpEntity) return false;
454-
return true;
455-
}
456-
457-
bool CScriptGameObject::isInventoryItem() const
458-
{
459-
auto l_tpEntity = smart_cast<CInventoryItem*>(&object());
460-
if (!l_tpEntity) return false;
461-
return true;
462-
}
463-
464-
bool CScriptGameObject::isInventoryOwner() const
465-
{
466-
auto l_tpEntity = smart_cast<CInventoryOwner*>(&object());
467-
if (!l_tpEntity) return false;
468-
return true;
469-
}
470-
471-
bool CScriptGameObject::isActor() const
472-
{
473-
auto l_tpEntity = smart_cast<CActor*>(&object());
474-
if (!l_tpEntity) return false;
475-
return true;
476-
}
477-
478-
bool CScriptGameObject::isCustomMonster() const
479-
{
480-
auto l_tpEntity = smart_cast<CCustomMonster*>(&object());
481-
if (!l_tpEntity) return false;
482-
return true;
483-
}
484-
485-
bool CScriptGameObject::isWeapon() const
486-
{
487-
auto l_tpEntity = smart_cast<CWeapon*>(&object());
488-
if (!l_tpEntity) return false;
489-
return true;
490-
}
491-
/*
492-
bool CScriptGameObject::isMedkit() const
493-
{
494-
auto l_tpEntity = smart_cast<CMedkit*>(&object());
495-
if (!l_tpEntity) return false;
496-
return true;
497-
}
498-
*/
499-
500-
/*
501-
bool CScriptGameObject::isEatableItem() const
502-
{
503-
auto l_tpEntity = smart_cast<CEatableItem*>(&object());
504-
if (!l_tpEntity) return false;
505-
return true;
506-
}
507-
*/
508-
509-
/*
510-
bool CScriptGameObject::isAntirad() const
511-
{
512-
auto l_tpEntity = smart_cast<CAntirad*>(&object());
513-
if (!l_tpEntity) return false;
514-
return true;
515-
}
516-
*/
517-
518-
bool CScriptGameObject::isCustomOutfit() const
519-
{
520-
auto l_tpEntity = smart_cast<CCustomOutfit*>(&object());
521-
if (!l_tpEntity) return false;
522-
return true;
523-
}
524-
525-
bool CScriptGameObject::isScope() const
526-
{
527-
auto l_tpEntity = smart_cast<CScope*>(&object());
528-
if (!l_tpEntity) return false;
529-
return true;
530-
}
531-
532-
bool CScriptGameObject::isSilencer() const
533-
{
534-
auto l_tpEntity = smart_cast<CSilencer*>(&object());
535-
if (!l_tpEntity) return false;
536-
return true;
537-
}
538-
539-
bool CScriptGameObject::isGrenadeLauncher() const
540-
{
541-
auto l_tpEntity = smart_cast<CGrenadeLauncher*>(&object());
542-
if (!l_tpEntity) return false;
543-
return true;
544-
}
545-
546-
bool CScriptGameObject::isWeaponMagazined() const
547-
{
548-
auto l_tpEntity = smart_cast<CWeaponMagazined*>(&object());
549-
if (!l_tpEntity) return false;
550-
return true;
551-
}
552-
553-
bool CScriptGameObject::isSpaceRestrictor() const
554-
{
555-
auto l_tpEntity = smart_cast<CSpaceRestrictor*>(&object());
556-
if (!l_tpEntity) return false;
557-
return true;
558-
}
559-
560-
bool CScriptGameObject::isStalker() const
561-
{
562-
auto l_tpEntity = smart_cast<CAI_Stalker*>(&object());
563-
if (!l_tpEntity) return false;
564-
return true;
565-
}
566-
567-
bool CScriptGameObject::isAnomaly() const
568-
{
569-
auto l_tpEntity = smart_cast<CCustomZone*>(&object());
570-
if (!l_tpEntity) return false;
571-
return true;
572-
}
573-
574-
bool CScriptGameObject::isMonster() const
575-
{
576-
auto l_tpEntity = smart_cast<CBaseMonster*>(&object());
577-
if (!l_tpEntity) return false;
578-
return true;
579-
}
580-
581-
/*
582-
bool CScriptGameObject::isExplosive() const
583-
{
584-
auto l_tpEntity = smart_cast<CExplosive*>(&object());
585-
if (!l_tpEntity) return false;
586-
return true;
587-
}
588-
*/
589-
590-
/*
591-
bool CScriptGameObject::isScriptZone() const
592-
{
593-
auto l_tpEntity = smart_cast<CScriptZone*>(&object());
594-
if (!l_tpEntity) return false;
595-
return true;
596-
}
597-
*/
598-
599-
/*
600-
bool CScriptGameObject::isProjector() const
601-
{
602-
auto l_tpEntity = smart_cast<CProjector*>(&object());
603-
if (!l_tpEntity) return false;
604-
return true;
605-
}
606-
*/
607-
608-
bool CScriptGameObject::isTrader() const
609-
{
610-
auto l_tpEntity = smart_cast<CAI_Trader*>(&object());
611-
if (!l_tpEntity) return false;
612-
return true;
613-
}
614-
615-
bool CScriptGameObject::isHudItem() const
616-
{
617-
auto l_tpEntity = smart_cast<CHudItem*>(&object());
618-
if (!l_tpEntity) return false;
619-
return true;
620-
}
621-
622-
/*
623-
bool CScriptGameObject::isFoodItem() const
624-
{
625-
auto l_tpEntity = smart_cast<CFoodItem*>(&object());
626-
if (!l_tpEntity) return false;
627-
return true;
628-
}
629-
*/
630-
631-
bool CScriptGameObject::isArtefact() const
632-
{
633-
auto l_tpEntity = smart_cast<CArtefact*>(&object());
634-
if (!l_tpEntity) return false;
635-
return true;
636-
}
637-
638-
bool CScriptGameObject::isAmmo() const
639-
{
640-
auto l_tpEntity = smart_cast<CWeaponAmmo*>(&object());
641-
if (!l_tpEntity) return false;
642-
return true;
643-
}
644-
645-
/*
646-
bool CScriptGameObject::isMissile() const
647-
{
648-
auto l_tpEntity = smart_cast<CMissile*>(&object());
649-
if (!l_tpEntity) return false;
650-
return true;
651-
}
652-
*/
653-
654-
/*
655-
bool CScriptGameObject::isPhysicsShellHolder() const
656-
{
657-
auto l_tpEntity = smart_cast<CPhysicsShellHolder*>(&object());
658-
if (!l_tpEntity) return false;
659-
return true;
660-
}
661-
*/
662-
663-
/*
664-
bool CScriptGameObject::isGrenade() const
665-
{
666-
auto l_tpEntity = smart_cast<CGrenade*>(&object());
667-
if (!l_tpEntity) return false;
668-
return true;
669-
}
670-
*/
671-
672-
/*
673-
bool CScriptGameObject::isBottleItem() const
674-
{
675-
auto l_tpEntity = smart_cast<CBottleItem*>(&object());
676-
if (!l_tpEntity) return false;
677-
return true;
678-
}
679-
*/
680-
681-
/*
682-
bool CScriptGameObject::isTorch() const
683-
{
684-
auto l_tpEntity = smart_cast<CTorch*>(&object());
685-
if (!l_tpEntity) return false;
686-
return true;
687-
}
688-
*/
689-
690-
bool CScriptGameObject::isWeaponGL() const
691-
{
692-
auto l_tpEntity = smart_cast<CWeaponMagazinedWGrenade*>(&object());
693-
if (!l_tpEntity) return false;
694-
return true;
695-
}
696-
697-
bool CScriptGameObject::isInventoryBox() const
698-
{
699-
auto l_tpEntity = smart_cast<CInventoryBox*>(&object());
700-
if (!l_tpEntity) return false;
701-
return true;
702-
}
703381
#endif
704-
//-AVO

0 commit comments

Comments
 (0)