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

Method CreateField

engine/Poseidon/Game/OperMap.cpp:936–983  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

934}
935
936OperField* OperMap::CreateField(int x, int z, int mask, EntityAI* veh)
937{
938 // x,z are in LandGrid units
939 if (!InRange(z, x))
940 {
941 return nullptr;
942 }
943
944 OperField* fld = nullptr;
945 // lookup map
946 int n = _fields.Size();
947 if (n > 50 * 50)
948 {
949 LOG_DEBUG(Script, "Very large OperMap");
950 }
951 for (int i = 0; i < n; i++)
952 {
953 if (_fields[i]->IsField(x, z))
954 {
955 fld = _fields[i];
956 break; // already in map
957 }
958 }
959
960 if (fld == nullptr)
961 {
962 if (mask & MASK_USE_BUFFER)
963 {
964 fld = GLOB_LAND->OperationalCache()->GetOperField(x, z, mask);
965 }
966 else
967 {
968 fld = new OperField(x, z, mask);
969 }
970 _fields.Add(fld);
971 for (int i = 0; i < fld->_doors.Size(); i++)
972 {
973 _doors.Add(fld->_doors[i]);
974 }
975 }
976
977 PoseidonAssert(InRange(x, z));
978 GeographyInfo geogr = GLOB_LAND->GetGeography(x, z);
979 fld->_baseCost = OperItemGrid * veh->GetCost(geogr);
980 fld->_heurCost = fld->_baseCost * veh->GetFieldCost(geogr);
981
982 return fld;
983}
984
985#include <Poseidon/World/Scene/Scene.hpp>
986

Callers 1

FindFreePositionMethod · 0.45

Calls 8

IsFieldMethod · 0.80
GetOperFieldMethod · 0.80
OperationalCacheMethod · 0.80
SizeMethod · 0.45
AddMethod · 0.45
GetGeographyMethod · 0.45
GetCostMethod · 0.45
GetFieldCostMethod · 0.45

Tested by

no test coverage detected