MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / NewObject

Function NewObject

engine/Poseidon/World/Scene/ObjectClasses.cpp:769–872  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

767DEF_RSB(church);
768
769Object* NewObject(LODShapeWithShadow* shape, int id)
770{
771 const RStringB& className = shape->GetPropertyClass();
772 if (className.GetLength() > 0)
773 {
774 if (className == RSB(forest))
775 {
776 BuildingType* type = dynamic_cast<BuildingType*>(VehicleTypes.FindShape(shape->Name()));
777 if (type)
778 {
779 type->VehicleAddRef();
780 Object* obj = new Forest(type, id);
781 type->VehicleRelease();
782 return obj;
783 }
784 // RptF("%s: no forest in config",(const char *)shape->Name());
785 return new ForestPlain(shape, id);
786 }
787 else if (className == RSB(road))
788 {
789 return new Road(shape, id);
790 }
791 else if (className == RSB(streetlamp))
792 {
793 // EntityType *vehType = VehicleTypes.New("StreetLamp");
794 EntityType* vehType = VehicleTypes.FindShapeAndSimulation(shape->Name(), className);
795 if (!vehType)
796 {
797 vehType = VehicleTypes.FindShape(shape->Name());
798 }
799 if (!vehType)
800 {
801 LOG_DEBUG(Graphics, "{}: {}, config class missing", shape->Name(), (const char*)className);
802 return new ObjectPlain(shape, id);
803 }
804 StreetLampType* type = dynamic_cast<StreetLampType*>(vehType);
805 if (!type)
806 {
807 LOG_DEBUG(Graphics, "{}: {}, config class not StreetLamp", shape->Name(), (const char*)className);
808 return new ObjectPlain(shape, id);
809 }
810 return new StreetLamp(shape, type, id);
811 }
812 else if (className == RSB(house) || className == RSB(vehicle) || className == RSB(church))
813 {
814 // search vehicle type bank for given shape
815 // prefer type with the same simulation
816 EntityType* vType = VehicleTypes.FindShapeAndSimulation(shape->Name(), className);
817 if (!vType)
818 {
819 // if not found, resort to any type with this shape
820 vType = VehicleTypes.FindShape(shape->Name());
821 }
822 if (!vType)
823 {
824 // it is not in config: ignore it
825 LOG_DEBUG(Graphics, "{}: {}, config class missing", shape->Name(), (const char*)className);
826 return new ObjectPlain(shape, id);

Callers 9

NewProxyObjectFunction · 0.70
convertToLODShapeFunction · 0.50
NewForestFunction · 0.50
ReplaceObjectsMethod · 0.50
AddObjectMethod · 0.50
ObjectCreateMethod · 0.50
SerializeBinMethod · 0.50
LoadMethod · 0.50
ScanProxiesMethod · 0.50

Calls 8

FindShapeMethod · 0.80
VehicleAddRefMethod · 0.80
VehicleReleaseMethod · 0.80
strcmpiFunction · 0.50
GetLengthMethod · 0.45
NameMethod · 0.45
GetNameMethod · 0.45

Tested by

no test coverage detected