C++03 Support & Partial Xbox 360 Support (#37)

* WIP C++03 + Xbox 360 Support

* math.h & _USE_MATH_DEFINES on Level.hpp
Updated Xenon vcxproj file for new file structure.

* * Fix bad GUI scale setup.

* * Gui: Use ratios instead of hardcoded sub-1 floating point values, to make the mechanism more clear.

* Add Direct Connect Button and Screen (#30)

* Add Direct Connect Button and Screen

* Remove accidental extra build directories for wasm

* Add DirectConnectScreen.cpp to the CMake

* Use Hungarian coding style notation

* * Fix errors caused by #30

* * Improve the Chat Screen

* * Improve the DirectConnectScreen, among other things.

* * Update the game title once again.

* * Add build-wasm.bat.

* * Add info about compiling for wasm

* * Fix send to specific GUID actually broadcasting to everyone

* * Add command manager.

* * Add writeable configuration.

* * Allow dynamic screen size change on windows

* * Allow the same thing on the emscripten version.

* WIP C++03 + Xbox 360 Support

* Fixed a possible merging issue that broke RakNet?

* Additional Xbox 360 compatability fixes

---------

Co-authored-by: Brent Da Mage <BrentDaMage@users.noreply.github.com>
Co-authored-by: iProgramInCpp <iprogramincpp@gmail.com>
Co-authored-by: ts <124226059+uniformization@users.noreply.github.com>
This commit is contained in:
Brent
2023-08-07 07:48:52 -05:00
committed by GitHub
parent 6c1a54e3f0
commit a0f71c7b27
179 changed files with 4969 additions and 918 deletions

View File

@@ -6,40 +6,32 @@
SPDX-License-Identifier: BSD-1-Clause
********************************************************************/
#include "Level.hpp"
#include <algorithm>
#include "client/common/Util.hpp"
#include "world/level/levelgen/chunk/ChunkCache.hpp"
#include "Level.hpp"
#include "Explosion.hpp"
#include "Region.hpp"
Level::Level(LevelStorage* pStor, const std::string& str, TLong seed, int x) :
field_38(1), // initialize with a seed of 1
m_pLevelStorage(pStor)
{
_init(str, seed, x, nullptr);
}
Level::Level(LevelStorage* pStor, const std::string& str, TLong seed, int x, Dimension *pDimension) :
field_38(1), // initialize with a seed of 1
m_pLevelStorage(pStor)
{
_init(str, seed, x, pDimension);
}
Level::~Level()
{
SAFE_DELETE(m_pChunkSource);
SAFE_DELETE(m_pDimension);
for (auto pEnt : m_entities)
delete pEnt;
m_entities.clear();
}
void Level::_init(const std::string& str, TLong seed, int x, Dimension* pDimension)
Level::Level(LevelStorage* pStor, const std::string& str, TLong seed, int x, Dimension *pDimension)
{
field_10 = 0;
field_11 = false;
field_12 = 0;
m_skyDarken = 0;
field_30 = 0;
m_pDimension = nullptr;
field_A00 = 0;
m_pChunkSource = nullptr;
m_pLevelStorage = pStor;
field_AA8 = 42184323;
field_AAC = 1013904223;
m_bUpdateLights = true;
field_B08 = 0;
field_B0C = 0;
field_38 = 1; // initialize with a seed of 1
LevelData* pData = m_pLevelStorage->prepareLevel(this);
@@ -62,6 +54,19 @@ void Level::_init(const std::string& str, TLong seed, int x, Dimension* pDimens
updateSkyBrightness();
}
Level::~Level()
{
SAFE_DELETE(m_pChunkSource);
SAFE_DELETE(m_pDimension);
const size_t size = m_entities.size();
for (int i = 0; i < size; i++)
{
delete m_entities.at(i);
}
m_entities.clear();
}
ChunkSource* Level::createChunkSource()
{
#ifndef MOD_USE_FLAT_WORLD
@@ -274,8 +279,9 @@ Material* Level::getMaterial(int x, int y, int z)
Entity* Level::getEntity(int id)
{
for (auto pEnt : m_entities)
for (auto it = m_entities.begin(); it != m_entities.end(); it++)
{
Entity* pEnt = *it;
if (pEnt->m_EntityID == id)
return pEnt;
}
@@ -387,8 +393,11 @@ void Level::setBrightness(const LightLayer& ll, int x, int y, int z, int bright)
LevelChunk* pChunk = getChunk(x >> 4, z >> 4);
pChunk->setBrightness(ll, x & 0xF, y, z & 0xF, bright);
for (auto pListener : m_levelListeners)
for (auto it = m_levelListeners.begin(); it != m_levelListeners.end(); it++)
{
LevelListener* pListener = *it;
pListener->tileBrightnessChanged(x, y, z);
}
}
int Level::getDirectSignal(int x, int y, int z, int dir)
@@ -603,8 +612,11 @@ bool Level::setTileNoUpdate(int x, int y, int z, TileID tile)
void Level::sendTileUpdated(int x, int y, int z)
{
for (auto pListener : m_levelListeners)
for (auto it = m_levelListeners.begin(); it != m_levelListeners.end(); it++)
{
LevelListener* pListener = *it;
pListener->tileChanged(x, y, z);
}
}
void Level::neighborChanged(int x, int y, int z, TileID tile)
@@ -664,20 +676,29 @@ bool Level::setTile(int x, int y, int z, TileID tile)
void Level::setTilesDirty(int x1, int y1, int z1, int x2, int y2, int z2)
{
for (auto pListener : m_levelListeners)
for (auto it = m_levelListeners.begin(); it != m_levelListeners.end(); it++)
{
LevelListener* pListener = *it;
pListener->setTilesDirty(x1, y1, z1, x2, y2, z2);
}
}
void Level::entityAdded(Entity* pEnt)
{
for (auto pListener : m_levelListeners)
for (auto it = m_levelListeners.begin(); it != m_levelListeners.end(); it++)
{
LevelListener* pListener = *it;
pListener->entityAdded(pEnt);
}
}
void Level::entityRemoved(Entity* pEnt)
{
for (auto pListener : m_levelListeners)
for (auto it = m_levelListeners.begin(); it != m_levelListeners.end(); it++)
{
LevelListener* pListener = *it;
pListener->entityRemoved(pEnt);
}
}
AABBVector* Level::getCubes(const Entity* pEntUnused, const AABB& aabb)
@@ -724,8 +745,9 @@ Entity* Level::getNearestPlayer(float x, float y, float z, float maxDist)
float dist = -1.0f;
Player* pPlayer = nullptr;
for (Player* player : m_players)
for (auto it = m_players.begin(); it != m_players.end(); it++)
{
Player* player = *it;
float ldist = player->distanceToSqr(x, y, z);
if ((maxDist < 0.0f || ldist < maxDist * maxDist) && (dist == -1.0f || dist > ldist))
{
@@ -1005,8 +1027,9 @@ void Level::removeAllPendingEntityRemovals()
{
Util::removeAll(m_entities, m_pendingEntityRemovals);
for (auto ent : m_pendingEntityRemovals)
for (auto it = m_pendingEntityRemovals.begin(); it != m_pendingEntityRemovals.end(); it++)
{
Entity* ent = *it;
ent->removed();
if (hasChunk(ent->m_chunkX, ent->m_chunkZ))
@@ -1214,8 +1237,9 @@ bool Level::isUnobstructed(AABB* aabb)
if (entities->size() <= 0)
return true;
for (auto pEnt : *entities)
for (auto it = entities->begin(); it != entities->end(); it++)
{
Entity* pEnt = *it;
if (pEnt->m_bRemoved)
continue;
@@ -1297,8 +1321,10 @@ void Level::tickTiles()
{
m_chunksToUpdate.clear();
for (auto player : m_players)
for (auto it = m_players.begin(); it != m_players.end(); it++)
{
Player* player = *it;
int chkX = Mth::floor(player->m_pos.x / 16.0f);
int chkZ = Mth::floor(player->m_pos.z / 16.0f);
@@ -1311,8 +1337,9 @@ void Level::tickTiles()
}
}
for (auto pos : m_chunksToUpdate)
for (auto it = m_chunksToUpdate.begin(); it != m_chunksToUpdate.end(); it++)
{
ChunkPos pos = *it;
LevelChunk* pChunk = getChunk(pos.x, pos.z);
int globX = pos.x * 16, globZ = pos.z * 16;
@@ -1403,8 +1430,11 @@ void Level::tick()
{
m_skyDarken = light;
for (auto pListener : m_levelListeners)
for (auto it = m_levelListeners.begin(); it != m_levelListeners.end(); it++)
{
LevelListener* pListener = *it;
pListener->skyColorChanged();
}
}
#endif
@@ -1825,26 +1855,38 @@ void Level::addToTickNextTick(int a, int b, int c, int d, int delay)
void Level::takePicture(TripodCamera* pCamera, Entity* pOwner)
{
for (auto pListener : m_levelListeners)
for (auto it = m_levelListeners.begin(); it != m_levelListeners.end(); it++)
{
LevelListener* pListener = *it;
pListener->takePicture(pCamera, pOwner);
}
}
void Level::addParticle(const std::string& name, float a, float b, float c, float d, float e, float f)
{
for (auto pListener : m_levelListeners)
for (auto it = m_levelListeners.begin(); it != m_levelListeners.end(); it++)
{
LevelListener* pListener = *it;
pListener->addParticle(name, a, b, c, d, e, f);
}
}
void Level::playSound(Entity* entity, const std::string& name, float a, float b)
{
for (auto pListener : m_levelListeners)
for (auto it = m_levelListeners.begin(); it != m_levelListeners.end(); it++)
{
LevelListener* pListener = *it;
pListener->playSound(name, entity->m_pos.x, entity->m_pos.y - entity->field_84, entity->m_pos.z, a, b);
}
}
void Level::playSound(float x, float y, float z, const std::string& name, float a, float b)
{
for (auto pListener : m_levelListeners)
for (auto it = m_levelListeners.begin(); it != m_levelListeners.end(); it++)
{
LevelListener* pListener = *it;
pListener->playSound(name, x, y, z, a, b);
}
}
void Level::animateTick(int x, int y, int z)
@@ -1912,8 +1954,11 @@ void Level::addEntities(const std::vector<Entity*>& entities)
{
m_entities.insert(m_entities.end(), entities.begin(), entities.end());
for (Entity* pEnt : entities)
for (auto it = m_entities.begin(); it != m_entities.end(); it++)
{
Entity* pEnt = *it;
entityAdded(pEnt);
}
}
// @UNUSED