This commit is contained in:
2024-03-14 17:49:43 +05:00
parent b9a1f27817
commit 5f7dd88557
33 changed files with 113 additions and 72 deletions
+46 -13
View File
@@ -145,15 +145,15 @@ TArray<FcppflatStruct> UcppGI::getFlatArr_(Fcppcoords coords, int& len)
auto output = TArray<FcppflatStruct>();
for (auto& flat : flatArray) {
auto flatcoords = Fcppcoords();
flatcoords.flat = coords.floor < 0 ? -2 : flat.FlatId; //ignore flat
flatcoords.floor =coords.floor<0?-2: flat.Floor;
flatcoords.flat = coords.flat < 0 ? -2 : flat.FlatId; //ignore flat
flatcoords.floor = coords.floor < 0 ? -2 : flat.Floor;
flatcoords.house = coords.house < 1 ? -2 : flat.House;
flatcoords.section = coords.section < 1 ? -2 : flat.Section;
flatcoords.type = coords.type < 0 ? -2 : flat.flatType;
flatcoords.zone = coords.zone < 1 ? -2 : flat.Zone;
bool dummy[6];
bool eq;
cppCoordsEq(coords, flatcoords, true, false, dummy[0], dummy[1], dummy[2], dummy[3], dummy[4], dummy[5], eq);
cppCoordsEq(coords, flatcoords, true, false, boolDummy, boolDummy, boolDummy, boolDummy, boolDummy, boolDummy, eq);
if (eq) output.Add(flat);
}
len = output.Num();
@@ -166,21 +166,27 @@ FcppflatStruct UcppGI::findFlatByCoords_(Fcppcoords coords, bool& success)
if (coords.flat < 0) return FcppflatStruct();
int len;
auto tt = getFlatArr_(coords, len);
if (len>1) UE_LOG(LogCore, Warning, TEXT("UcppGI::findFlatByCoords: found more than one flat"));
if (len==0) return FcppflatStruct();
if (len > 1) UE_LOG(LogCore, Warning, TEXT("UcppGI::findFlatByCoords: found more than one flat"));
if (len == 0) return FcppflatStruct();
success = true;
return tt[0];
}
TArray<FcppflatStruct> UcppGI::findFlatsByN_(int num, bool& success)
FcppflatStruct UcppGI::findFlatByN_(Fcppcoords filter, int num, bool& success)
{
success = false;
auto output = TArray<FcppflatStruct>();
for (auto& flat : flatArray) {
if (flat.FlatN == num) output.Add(flat);
filter.flat = -2;
auto output = FcppflatStruct();
auto arr = getFlatArr_(filter, intDummy);
for (auto& flat : arr) {
if (flat.FlatN == num) {
if (!success) output = flat;
else UE_LOG(LogCore, Warning, TEXT("UcppGI::findFlatByN_: found more than one flat"));
success = true;
}
}
success = !output.IsEmpty();
return output;
}
@@ -189,7 +195,7 @@ void UcppGI::countFreeApartments(Fcppcoords coords, int& free, int& all, float&
int len;
free = 0;
minPrice = 0;
bool temp=false;
bool temp = false;
for (auto& flat : getFlatArr_(coords, len)) {
if (flat.available) {
if (!temp) {
@@ -205,3 +211,30 @@ void UcppGI::countFreeApartments(Fcppcoords coords, int& free, int& all, float&
return;
}
void UcppGI::cppFlatTocppCoords(FcppflatStruct flat, Fcppcoords& coords)
{
coords.flat = flat.FlatId;
coords.floor = flat.Floor;
coords.house = flat.House;
coords.section = flat.Section;
coords.type = flat.flatType;
coords.zone = flat.Zone;
}
void UcppGI::cppCoordsToCppFlat(UObject* WorldContextObject, Fcppcoords coords, FcppflatStruct& flat, bool onlyCoords)
{
if (onlyCoords) {
flat.FlatId = coords.flat;
flat.Floor = coords.floor;
flat.House = coords.house;
flat.Section = coords.section;
flat.flatType = coords.type;
flat.Zone = coords.zone;
return;
}
bool dum;
flat = StaticCastPtr<UcppGI,UGameInstance>(UGameplayStatics::GetGameInstance(WorldContextObject))->findFlatByCoords_(coords, dum);
}