rodecomp/Source/Contents/MapSkyMgr.cpp
ragnarok-clanker dc3d5ce1a5 Maintenance: Resubmission of 14942 (gate: three existing in-class helpers whose lines changed lacked an annotation; marked // INLINED
Batch #14943 by ragnarok-clanker: no function's compiled code changes; checked with 741 compiled unit(s), including every includer of Source/ActorPickNode.h, Source/Client/Browser/BrowserClientSite.h, Source/Client/Browser/BrowserPopupDispatch.h, Source/Client/Mode/CGameMode.h, Source/Client/Mode/CLoginMode.h, Source/Client/Mode/CMode.h, Source/Client/Mode/ModeDragState.h, Source/Client/Replay.h, Source/Client/Session.h, Source/Client/Stove/StoveMgr.h, Source/Contents/AchievementMgr.h, Source/Contents/ActorNameCard.h, Source/Contents/Actors/CharacterRender.h, Source/Contents/Actors/EffectActors.h, Source/Contents/Actors/GameActor.h, Source/Contents/Actors/GrannyGameActor.h, Source/Contents/Actors/GroundScope.h, Source/Contents/Actors/Item.h, Source/Contents/Actors/Npc.h, Source/Contents/Actors/Pc.h, Source/Contents/Actors/RenderObjectState.h, Source/Contents/Actors/Skill.h, Source/Contents/AdventureGuideMgr.h, Source/Contents/Camera/Camera.h, Source/Contents/Camera/CameraState.h, Source/Contents/CashEmotionMgr.h, Source/Contents/Configuration/GameSettingsMgr.h, Source/Contents/EffectResourceSwitcher.h, Source/Contents/Effects/AMachineEffect.h, Source/Contents/Effects/AcidifiedThrow.h, Source/Contents/Effects/AxeBoomerang.h, Source/Contents/Effects/BlastForge.h, Source/Contents/Effects/CaneOfEvilEyeEffect.h, Source/Contents/Effects/CharacterParticleBundle.h, Source/Contents/Effects/CloudKillEffect.h, Source/Contents/Effects/Effect.h, Source/Contents/Effects/EffectActor.h, Source/Contents/Effects/EffectEmitter.h, Source/Contents/Effects/EffectMaker.h, Source/Contents/Effects/EffectPrimitiveState.h, Source/Contents/Effects/FuumaShouakuEffect.h, Source/Contents/Effects/GravityControlEffect.h, Source/Contents/Effects/HealSpEffect.h, Source/Contents/Effects/Level99Effect.h, Source/Contents/Effects/MapChainEffect.h, Source/Contents/Effects/MonsterSkillEffects.h, Source/Contents/Effects/MsgEffect.h, Source/Contents/Effects/NyanggrassEffect.h, Source/Contents/Effects/Particle.h, Source/Contents/Effects/PowderingEffect.h, Source/Contents/Effects/RagEffectState.h, Source/Contents/Effects/RectUpEffect.h, Source/Contents/Effects/ShadowExceedEffect.h, Source/Contents/Effects/SkillEffects.h, Source/Contents/Effects/SpriteParticle.h, Source/Contents/Effects/StormCannonEffect.h, Source/Contents/Effects/ThrowEffects.h, Source/Contents/EntryQueueMgr.h, Source/Contents/EquipmentResourceMgr.h, Source/Contents/FlyingShipRouteInfo.h, Source/Contents/Ground/GroundGeometry.h, Source/Contents/GuildInfo.h, Source/Contents/Items/ItemDescription.h, Source/Contents/Items/ItemInfo.h, Source/Contents/MapSkyMgr.h, Source/Contents/Messenger/MessengerWindows.h, Source/Contents/Models/ModelNode.h, Source/Contents/NavigationManager.h, Source/Contents/Party/AdventurerAgencyMgr.h, Source/Contents/RDamageVar.h, Source/Contents/RenewQuestMgr.h, Source/Contents/ReputeMgr.h, Source/Contents/RodexMailStore.h, Source/Contents/RouletteMgr.h, Source/Contents/Schedule/Schedule.h, Source/Contents/SignBoard/SignBoard.h, Source/Contents/Skills/ClientSkills.h, Source/Contents/Skills/PlayerSkillBundle.h, Source/Contents/Skills/SkillInfo.h, Source/Contents/SpriteLayerDrawing.h, Source/Contents/TipBoxTitles.h, Source/Contents/UserData/AccountLinkedUserDataMgr.h, Source/Contents/UserData/NormalItemSlots.h, Source/Contents/World/World.h, Source/Contents/WorldView/WorldViewData.h, Source/Render/Primitives/LightmappedPrimitive.h, Source/Render/Primitives/RenderPrimitive.h, Source/Render/Renderer.h, Source/Render/Textures/SpritePixels.h, Source/Render/Textures/Texture.h, Source/Resource/EZeffectResource.h, Source/Resource/Models/AnimatedModelResource.h, Source/Resource/Models/GrannyModelResource.h, Source/Resource/Sprites/ActionResource.h, Source/Resource/World/GroundResource.h, Source/Resource/World/WorldResource.h, Source/Resource/XmlNode.h, Source/UI/AdventureGuide/UIAdventureGuide.h, Source/UI/Buttons/UIBmpRadioBtn.h, Source/UI/Buttons/UIDescriptRace.h, Source/UI/Buttons/UIItemTagButton.h, Source/UI/Buttons/UISlotBmpButton.h, Source/UI/Buttons/UISpriteButton.h, Source/UI/Buttons/UITVTextButton.h, Source/UI/Buttons/UITextureButton.h, Source/UI/CashEmotion/UICashEmotionListWnd.h, Source/UI/CashEmotion/UICashEmotionPack.h, Source/UI/CashShop/UICashShopWnd.h, Source/UI/Chat/UIChatRoomMakeWnd.h, Source/UI/Chat/UIChatRoomTitle.h, Source/UI/Chat/UINewChatWnd.h, Source/UI/Chat/UISubChatHisWnd.h, Source/UI/Chat/UISubChatMiniWnd.h, Source/UI/Chat/UIWhisperWnd.h, Source/UI/Clan/UIClanWnd.h, Source/UI/Dialogs/UIBookWnd.h, Source/UI/Dialogs/UIChooseWarpWnd.h, Source/UI/Dialogs/UIMenuWnd.h, Source/UI/Dialogs/UIMiniMapWnd.h, Source/UI/Dialogs/UIMinimapZoomWnd.h, Source/UI/Dialogs/UINpcEditDialogWnd.h, Source/UI/Dialogs/UIPasswordWnd.h, Source/UI/Dialogs/UISayDialogWnd.h, Source/UI/Dialogs/UISelectCartWnd.h, Source/UI/Dialogs/UITipboxWnd.h, Source/UI/Edit/UIEditBoxEx.h, Source/UI/Edit/UIEditCtrl.h, Source/UI/Edit/UIEditCtrl_Currency.h, Source/UI/Edit/UIItemTagCtrl.h, Source/UI/Enchant/EnchantUI.h, Source/UI/Exchange/UIExchangeUI.h, Source/UI/FrameSkin.h, Source/UI/GameSettings/GameSettingsUI.h, Source/UI/Gauges/UIPcGage.h, Source/UI/Guild/UIGuildHelperWnd.h, Source/UI/Guild/UIGuildWnd.h, Source/UI/Guild/UIGuild_Storage_Log.h, Source/UI/Item/UIEquipmentPropertiesWnd.h, Source/UI/Item/UIItemBaseWnd.h, Source/UI/Item/UIItemPurchaseWnd.h, Source/UI/Item/UIItemSellWnd2.h, Source/UI/Item/UIItemShopWnd.h, Source/UI/Item/UIItemShopWnd2.h, Source/UI/Item/UIItemStoreFindWnd.h, Source/UI/Item/UIItemStoreSubWnd.h, Source/UI/Item/UIItemStoreWnd.h, Source/UI/Item/UIItemWnd.h, Source/UI/Item/UIMerchantItemLogWnd.h, Source/UI/Item/UIParaItemShopWnd.h, Source/UI/Items/UICardItemIllustWnd.h, Source/UI/Items/UIEquipWnd.h, Source/UI/Items/UIExchangeWnd.h, Source/UI/Items/UIGameItem.h, Source/UI/Items/UIItemCollectionWnd.h, Source/UI/Items/UIItemIdentifyWnd.h, Source/UI/Items/UIItemParamChangeDisplayWnd.h, Source/UI/Items/UISwapEquipmentWnd.h, Source/UI/Layout/WindowGeometry.h, Source/UI/Lists/UIChatHisBox.h, Source/UI/Lists/UIComboBoxV2Wnd.h, Source/UI/Lists/UIImgMenu.h, Source/UI/Lists/UIListBoxID.h, Source/UI/Lists/UIListBoxTemplate.h, Source/UI/Lists/UIMemberListBox.h, Source/UI/Lists/UITabControl.h, Source/UI/Lists/UITagListBox.h, Source/UI/Lists/UITreeView.h, Source/UI/Menu/UIMenuIconWnd.h, Source/UI/Navigation/UINavigationV4Wnd.h, Source/UI/ProbabilityTable/UIProbabilityTable.h, Source/UI/Quest/UIQuestDisplay.h, Source/UI/Quest/UIRenewQuestUI.h, Source/UI/Quest/UIRenewQuestWnd.h, Source/UI/Rodex/UIRodexComposeWnd.h, Source/UI/Rodex/UIRodexInboxWnd.h, Source/UI/RuneSystem/UIRuneSystemWindows.h, Source/UI/RuneSystem/UIRuneSystemWnd.h, Source/UI/Shop/UIMerchantItemMyShopWnd.h, Source/UI/Shop/UIMerchantItemPurchaseMSGWnd.h, Source/UI/Shop/UIMerchantItemPurchaseWnd.h, Source/UI/Shop/UIMerchantItemShopWnd.h, Source/UI/Shop/UIMerchantMirrorItemWnd.h, Source/UI/Shop/UIMerchantShopMakeWnd.h, Source/UI/Shop/UIMerchantShopTitle.h, Source/UI/Skill/UISkillDescribeWnd.h, Source/UI/Skill/UISkillListWnd.h, Source/UI/SkillDelayInfo/SkillDelayInfo.h, Source/UI/StylingShop/UIStylingShopWnd.h, Source/UI/Text/CreateLineInfo.h, Source/UI/Text/UIAchWnd.h, Source/UI/Text/UIBalloonText.h, Source/UI/Text/UINameBalloonText.h, Source/UI/Text/UIStaticTextControl.h, Source/UI/Text/UIString.h, Source/UI/Text/UITextViewerControl.h, Source/UI/UIBarGraph.h, Source/UI/UIBartermarketWnd.h, Source/UI/UIChangeMaterialWnd.h, Source/UI/UIGradeEnchantWnd.h, Source/UI/UILapineScrollBar.h, Source/UI/UIMacroBlackListCheckWnd.h, Source/UI/UIMacroDetectorWnd.h, Source/UI/UIMacroReport.h, Source/UI/UIMacroUserInfoWnd.h, Source/UI/UIPreviewEquipWnd.h, Source/UI/UIRefiningWnd.h, Source/UI/UIScrollWnd.h, Source/UI/UISlotBitmap.h, Source/UI/Window/FuncDrawWNDChar.h, Source/UI/Window/UIBattleMsgOptionWnd.h, Source/UI/Window/UIChatRoomWnd.h, Source/UI/Window/UICollectionSystemWnd.h, Source/UI/Window/UIControl.h, Source/UI/Window/UIHomunInfoWnd.h, Source/UI/Window/UIHotKeyWnd.h, Source/UI/Window/UIJobListWnd.h, Source/UI/Window/UILoginOTPWnd.h, Source/UI/Window/UILoginWnd.h, Source/UI/Window/UIMakeCharWnd.h, Source/UI/Window/UIMonsterDisplayWnd.h, Source/UI/Window/UIMonsterInfoWnd.h, Source/UI/Window/UINavigationHelpWnd.h, Source/UI/Window/UINavigationWnd.h, Source/UI/Window/UINewMakeCharWnd.h, Source/UI/Window/UINewSelectCharWnd.h, Source/UI/Window/UINoticeWnd.h, Source/UI/Window/UIPetInfoWnd.h, Source/UI/Window/UIRegisterMgr.h, Source/UI/Window/UIRoMapWnd.h, Source/UI/Window/UIRodexContentsWnd.h, Source/UI/Window/UISecondCostumeWnd.h, Source/UI/Window/UISeekPartyMBWnd.h, Source/UI/Window/UISeekPartyWnd.h, Source/UI/Window/UISelCharForUServerWnd.h, Source/UI/Window/UISerachStoreInfoWnd.h, Source/UI/Window/UITransMenuWnd.h, Source/UI/Window/UIWindow.h, Source/UI/Window/UIWindowMgr.h, Source/UI/Window/UIWindowMgr.inl, Source/Utility/Lexicon/LexiconSerializer.h.
2026-11-08 16:44:36 +00:00

479 lines
14 KiB
C++

#include "Contents/MapSkyMgr.h"
#include "Client/Mode/CGameMode.h"
#include "Client/Mode/ModeMgr.h"
#include "Client/Session.h"
#include "Contents/Configuration/ServiceOptions.h"
#include "Contents/Effects/EffectActor.h"
#include "Contents/Effects/EffectLists.h"
#include "Contents/Effects/RagEffect.h"
#include "Contents/World/World.h"
#include "File/MapName.h"
#include "Render/Renderer.h"
#include "Resource/World/TerrainResource.h"
#include "Utility/Math/AffineMatrix.h"
#include <cctype>
#include <cstdlib>
#include <new>
struct MapSkyCloud : CEffect {
/* 00CC */ unsigned char unknown_00CC[0x28];
/* 00F4 */ unsigned char colorR;
/* 00F5 */ unsigned char colorG;
/* 00F6 */ unsigned char colorB;
/* 00F7 */ unsigned char unknown_00F7;
/* 00F8 */ float velocityX;
/* 00FC */ float velocityY;
/* 0100 */ float velocityZ;
/* 0104 */ float scriptFloatParameterA;
/* 0108 */ float scriptFloatParameterB;
/* 010C */ int scriptIntegerParameterA;
/* 0110 */ int scriptIntegerParameterB;
/* 0114 */ int scriptIntegerParameterC;
/* 0118 */ int scriptIntegerParameterD;
/* 011C */ float scriptFloatParameterC;
/* 0120 */ float spanX;
/* 0124 */ float spanZ;
/* 0128 */ unsigned char flag;
};
// GLOBAL: gl_24482
CWeatherEffect g_weatherEffect;
// GLOBAL: gl_24633
float g_depthAverageHalf = 0.5f;
static_assert(sizeof(std::vector<std::string>) == 12);
// OFFSET: 0x005B8D50
// FUNCTION: fn_03431
CMapSkyMgr::CMapSkyMgr() : m_script(nullptr) {
this->m_script = new LuaScript();
this->m_script->Open();
}
// OFFSET: 0x005B8DD0
// FUNCTION: fn_03432
void CMapSkyMgr::Unused() {
}
// OFFSET: 0x005B8F00
// FUNCTION: fn_03435
bool CMapSkyMgr::LoadData() {
return this->m_script->Load("Lua Files\\MapSkyData\\MapSkyData", true, false);
}
// OFFSET: 0x00C7B200
// FUNCTION: fn_20362
CWeatherEffect::CWeatherEffect()
: darken(0), enabled(1), lightning(0), actor(nullptr), targetColor{}, effect(nullptr), counter(0) {
this->color[0] = 1.0f;
this->color[1] = 1.0f;
this->color[2] = 1.0f;
this->fog[0] = 0.0f;
this->fog[1] = 0.0f;
this->fog[2] = 0.0f;
this->lightColor[0] = 1.0f;
this->lightColor[1] = 1.0f;
this->lightColor[2] = 1.0f;
}
// OFFSET: 0x00C7B530
// FUNCTION: fn_20365
void CWeatherEffect::AddMapWeather(std::string mapName, std::string weather) {
std::pair<std::string, std::string> entry;
entry.second = weather;
entry.first = mapName;
this->mapWeathers.push_back(std::move(entry));
}
// OFFSET: 0x00C7B6F0
// FUNCTION: fn_20366
vector3d CWeatherEffect::GetWindDirection() const {
vector3d direction = {0.0f, 0.0f, 0.0f};
const float sine = ClientSine((this->counter >> 3) + 90);
const float cosine = ClientCosine((this->counter >> 3) + 90);
direction.z = 0.0f;
direction.x = cosine * 1000.0f + sine * 0.0f;
direction.y = cosine * 0.0f - sine * 1000.0f;
return direction;
}
// OFFSET: 0x00C7B790
// FUNCTION: fn_20367
__declspec(noinline) void CWeatherEffect::Play(char kind) {
if (this->effect && this->effect->GetDuration() - this->effect->state.stateCnt <= 300) {
return;
}
CGameMode* mode = static_cast<CGameMode*>(g_modeMgr.GetGameMode());
this->actor = mode->scene->player;
if (kind == 0) {
this->effect = static_cast<EffectActor*>(this->actor)->LaunchEffect(0xe5, vector3d{0.0f, 0.0f, 0.0f}, 0.0f);
} else if (kind == 1) {
this->effect = static_cast<EffectActor*>(this->actor)->LaunchEffect(0xe6, vector3d{0.0f, 0.0f, 0.0f}, 0.0f);
} else if (kind == 2) {
this->effect = static_cast<EffectActor*>(this->actor)->LaunchEffect(0xe9, vector3d{0.0f, 0.0f, 0.0f}, 0.0f);
} else if (kind == 3) {
this->effect = static_cast<EffectActor*>(this->actor)->LaunchEffect(0x203, vector3d{0.0f, 0.0f, 0.0f}, 0.0f);
} else if (kind == 4) {
this->effect = static_cast<EffectActor*>(this->actor)->LaunchEffect(0x204, vector3d{0.0f, 0.0f, 0.0f}, 0.0f);
} else if (kind == 5) {
this->effect = static_cast<EffectActor*>(this->actor)->LaunchEffect(0x250, vector3d{0.0f, 0.0f, 0.0f}, 0.0f);
} else if (kind == 7) {
this->effect = static_cast<EffectActor*>(this->actor)->LaunchEffect(0x2b9, vector3d{0.0f, 0.0f, 0.0f}, 0.0f);
} else if (kind == 8) {
this->effect = static_cast<EffectActor*>(this->actor)->LaunchEffect(0x2ba, vector3d{0.0f, 0.0f, 0.0f}, 0.0f);
} else if (kind == 9) {
this->effect = static_cast<EffectActor*>(this->actor)->LaunchEffect(0x3b1, vector3d{0.0f, 0.0f, 0.0f}, 0.0f);
} else if (kind == 10) {
this->effect = static_cast<EffectActor*>(this->actor)->LaunchEffect(0x415, vector3d{0.0f, 0.0f, 0.0f}, 0.0f);
} else if (kind == 11) {
this->effect = static_cast<EffectActor*>(this->actor)->LaunchEffect(0x45b, vector3d{0.0f, 0.0f, 0.0f}, 0.0f);
} else if (kind == 15) {
this->effect = static_cast<EffectActor*>(this->actor)->LaunchEffect(0x479, vector3d{0.0f, 0.0f, 0.0f}, 0.0f);
}
}
// OFFSET: 0x00C7B9E0
// FUNCTION: fn_20368
void CWeatherEffect::StartDarken() {
this->darken = 1;
}
// OFFSET: 0x00C7B9F0
// FUNCTION: fn_20369
void CWeatherEffect::Fireworks() {
CGameMode* mode = static_cast<CGameMode*>(g_modeMgr.GetGameMode());
this->actor = mode->scene->player;
static_cast<EffectActor*>(this->actor)->LaunchEffect(0x12d, vector3d{0.0f, 0.0f, 0.0f}, 0.0f);
for (int count = 0; count < 160; ++count) {
static_cast<EffectActor*>(this->actor)->LaunchEffect(0x129, vector3d{0.0f, 0.0f, 0.0f}, 0.0f);
}
}
// OFFSET: 0x00C7BB20
// FUNCTION: fn_20370
void CWeatherEffect::Snow() {
if (this->effect && this->effect->GetDuration() - this->effect->state.stateCnt <= 300) {
return;
}
CGameMode* mode = static_cast<CGameMode*>(g_modeMgr.GetGameMode());
this->actor = mode->scene->player;
this->effect = static_cast<EffectActor*>(this->actor)->LaunchEffect(0xa2, vector3d{0.0f, 0.0f, 0.0f}, 0.0f);
}
// OFFSET: 0x00C7BBA0
// FUNCTION: fn_20371
void CWeatherEffect::StartLightning() {
this->lightning = 1;
this->counter = 0;
}
// OFFSET: 0x00C7BBB0
// FUNCTION: fn_20372
void CWeatherEffect::Process() {
if (this->darken == 1) {
if (this->color[0] > 0.5f) {
this->color[0] -= 0.005f;
}
if (this->color[1] > 0.5f) {
this->color[1] -= 0.005f;
}
} else if (this->lightning == 1) {
++this->counter;
if (this->counter > 1000) {
this->lightning = 0;
}
if ((this->counter / 3 & 1) == 0) {
this->color[0] = 0.2f;
this->color[1] = 0.2f;
} else {
this->color[0] = 1.0f;
this->color[1] = 1.0f;
}
} else {
for (int index = 0; index < 3; ++index) {
if (this->color[index] < 1.0f && this->color[index] < this->targetColor[index]) {
this->color[index] += 0.005f;
}
}
}
if (this->effect && !static_cast<EffectActor*>(this->actor)->Contains(reinterpret_cast<const RagEffectState*>(this->effect))) {
this->effect = nullptr;
}
this->lightColor[0] = 1.0f - (1.0f - this->fog[0]) * (1.0f - this->color[0]);
this->lightColor[1] = 1.0f - (1.0f - this->fog[1]) * (1.0f - this->color[1]);
this->lightColor[2] = 1.0f - (1.0f - this->fog[2]) * (1.0f - this->color[2]);
}
// OFFSET: 0x00C7BD30
// FUNCTION: fn_20373
void CWeatherEffect::ResetEffect() {
this->effect = nullptr;
}
// OFFSET: 0x00C7BD40
// FUNCTION: fn_20374
void CWeatherEffect::ApplyMapWeather(std::string mapName) {
if (!g_serviceOptions.Get(8)) {
return;
}
for (auto entry = this->mapWeathers.begin(); entry != this->mapWeathers.end(); ++entry) {
if (entry->first != mapName) {
continue;
}
if (entry->second == "snow") {
if (!this->effect || this->effect->GetDuration() - this->effect->state.stateCnt > 300) {
CGameMode* mode = static_cast<CGameMode*>(g_modeMgr.GetGameMode());
this->actor = mode->scene->player;
this->effect = static_cast<EffectActor*>(this->actor)->LaunchEffect(0xa2, vector3d{0.0f, 0.0f, 0.0f}, 0.0f);
}
} else if (entry->second == "sakura") {
if (!this->effect || this->effect->GetDuration() - this->effect->state.stateCnt > 300) {
CGameMode* mode = static_cast<CGameMode*>(g_modeMgr.GetGameMode());
this->actor = mode->scene->player;
this->effect = static_cast<EffectActor*>(this->actor)->LaunchEffect(0xa3, vector3d{0.0f, 0.0f, 0.0f}, 0.0f);
}
} else if (entry->second == "pokjuk") {
CGameMode* mode = static_cast<CGameMode*>(g_modeMgr.GetGameMode());
this->actor = mode->scene->player;
static_cast<EffectActor*>(this->actor)->LaunchEffect(0x12d, vector3d{0.0f, 0.0f, 0.0f}, 0.0f);
for (int count = 0; count < 160; ++count) {
static_cast<EffectActor*>(this->actor)->LaunchEffect(0x129, vector3d{0.0f, 0.0f, 0.0f}, 0.0f);
}
}
}
}
// OFFSET: 0x00C7C010
// FUNCTION: fn_20375
void CWeatherEffect::Unused() {
}
// OFFSET: 0x00C7C040
// FUNCTION: fn_20376
void CWeatherEffect::StopDarken() {
this->darken = 0;
}
// OFFSET: 0x00C7C070
// FUNCTION: fn_20377
void CWeatherEffect::ExtendEffect() {
if (this->effect) {
this->effect->SetStateDuration(this->effect->state.stateCnt + 300);
}
}
// OFFSET: 0x00C7C090
// FUNCTION: fn_20378
void CWeatherEffect::StopLightning() {
this->lightning = 0;
}
// OFFSET: 0x005B90F0
// FUNCTION: fn_03436
void CMapSkyMgr::CreateClouds(const std::string& mapName) {
int typeCount = 0;
this->m_script->Call("GetCloudTypeNum", "s>d", mapName.c_str(), &typeCount);
const int mapWidth =
static_cast<CGameMode*>(g_modeMgr.GetGameMode())->scene->terrain->width * static_cast<CGameMode*>(g_modeMgr.GetGameMode())->scene->terrain->cellSize;
const int mapHeight =
static_cast<CGameMode*>(g_modeMgr.GetGameMode())->scene->terrain->height * static_cast<CGameMode*>(g_modeMgr.GetGameMode())->scene->terrain->cellSize;
for (int type = 1; type <= typeCount; ++type) {
int count = 0;
int range = 0x82;
int red = 0;
int green = 0;
int blue = 0;
double velX = 0.0;
double velY = 0.0;
double velZ = 0.0;
int param0 = 0;
int param1 = 0;
double param2 = 0.0;
int param3 = 0;
int param4 = 0;
double param5 = 0.0;
double posY = 0.0;
double param7 = 0.0;
unsigned char flag = 1;
this->m_script->Call(
"GetCloudInfo",
"sd>dddddlllddlddlllb",
mapName.c_str(),
type,
&count,
&range,
&red,
&green,
&blue,
&velX,
&velY,
&velZ,
&param0,
&param1,
&param2,
&param3,
&param4,
&param5,
&posY,
&param7,
&flag
);
const float spanX = static_cast<float>(mapWidth) / static_cast<float>(count + 1);
const float spanZ = static_cast<float>(mapHeight) / static_cast<float>(count + 1);
if (count <= 0) {
continue;
}
const int halfWidth = static_cast<int>(static_cast<float>(mapWidth) * 0.5f);
const int halfHeight = static_cast<int>(static_cast<float>(mapHeight) * 0.5f);
for (int index = 0; index < count; ++index) {
const int signX = rand() % 2;
int offsetX = 0;
if (halfWidth != 0) {
offsetX = rand() % halfWidth;
if (offsetX < 0) {
offsetX = 0;
}
}
const float x = static_cast<float>((1 - 2 * signX) * offsetX);
const int signZ = rand() % 2;
int offsetZ = 0;
if (halfHeight != 0) {
offsetZ = rand() % halfHeight;
if (offsetZ < 0) {
offsetZ = 0;
}
}
const float z = static_cast<float>((1 - 2 * signZ) * offsetZ);
const float y = static_cast<float>(posY);
CEffect* spawned = g_effectMgr->Spawn(0, 0x47a, x, y, z, 0, -1, 0, 0);
if (!spawned) {
continue;
}
auto* cloud = static_cast<MapSkyCloud*>(spawned);
cloud->range = range;
cloud->colorR = static_cast<unsigned char>(red);
cloud->colorG = static_cast<unsigned char>(green);
cloud->colorB = static_cast<unsigned char>(blue);
cloud->velocityX = static_cast<float>(velX);
cloud->velocityY = static_cast<float>(velY);
cloud->velocityZ = static_cast<float>(velZ);
cloud->scriptIntegerParameterA = param0;
cloud->scriptIntegerParameterB = param1;
cloud->scriptIntegerParameterC = param3;
cloud->scriptIntegerParameterD = param4;
cloud->scriptFloatParameterA = static_cast<float>(param2);
cloud->scriptFloatParameterB = static_cast<float>(param5);
cloud->scriptFloatParameterC = static_cast<float>(param7);
cloud->spanX = spanX;
cloud->spanZ = spanZ;
cloud->flag = flag;
cloud->ResetParticles();
}
}
}
// OFFSET: 0x005B95F0
// FUNCTION: fn_03437
void CMapSkyMgr::Apply(const std::string& mapName) {
std::string sky = ScriptMapName(mapName);
unsigned char exists = 0;
this->m_script->Call("IsExistMapSkyData", "s>b", sky.c_str(), &exists);
if (exists == 0) {
g_renderer->SetClearColor(0xFF000000u);
return;
}
int red = 0;
int green = 0;
int blue = 0;
this->m_script->Call("GetBackgroundColor", "s>ddd", sky.c_str(), &red, &green, &blue);
g_renderer->SetClearColor(
0xFF000000u | ((static_cast<unsigned>(red) & 255u) << 16) | ((static_cast<unsigned>(green) & 255u) << 8) | (static_cast<unsigned>(blue) & 255u)
);
unsigned char drawStar = 0;
this->m_script->Call("IsDrawStar", "s>b", sky.c_str(), &drawStar);
if (drawStar == 1) {
g_weatherEffect.Play(9);
}
this->CreateClouds(sky);
int oldCount = 0;
this->m_script->Call("GetOldCloudTypeNum", "s>d", sky.c_str(), &oldCount);
for (int index = 1; index <= oldCount; ++index) {
int info = -1;
this->m_script->Call("GetOldCloudInfo", "sd>d", sky.c_str(), index, &info);
if (info != -1) {
g_weatherEffect.Play(static_cast<char>(info));
}
}
unsigned char fog = 0;
this->m_script->Call("IsBackGroundFog", "s>b", sky.c_str(), &fog);
if (fog == 1) {
static_cast<CGameMode*>(g_modeMgr.GetGameMode())->scene->backgroundFog = true;
}
}
// GLOBAL: gl_24480
CMapSkyMgr* g_mapSkyMgr;
// OFFSET: 0x00E5CFB0
// FUNCTION: fn_24375
CMapSkyMgr* GetMapSkyMgr() {
if (!g_mapSkyMgr) {
g_mapSkyMgr = new (std::nothrow) CMapSkyMgr;
}
return g_mapSkyMgr;
}
// OFFSET: 0x00E5D100
// FUNCTION: fn_24378
void IgnoreNull() {
}
// OFFSET: 0x00E5D110
// FUNCTION: fn_24379
void RegisterLowercaseName(const char* name) {
if (!name) {
return;
}
std::string lowered(name);
for (char& character : lowered) {
character = static_cast<char>(std::tolower(static_cast<unsigned char>(character)));
}
for (const std::string& entry : g_session.skyMapNames) {
if (entry == lowered) {
return;
}
}
g_session.skyMapNames.push_back(lowered.c_str());
}