mirror of
https://github.com/celisej567/mcpe.git
synced 2026-01-04 14:09:47 +03:00
Mac OS X 10.6 & More C++03 Support (#68)
* Mac OS X 10.6 & More C++03 Support * Fix SDL2 options.txt loading for C++03 --------- Co-authored-by: Brent Da Mage <BrentDaMage@users.noreply.github.com>
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -373,6 +373,10 @@ xcuserdata/
|
||||
*.xcscmblueprint
|
||||
*.xccheckout
|
||||
|
||||
## Xcode 3
|
||||
*.mode1v3
|
||||
*.pbxuser
|
||||
|
||||
## Kill .DS_Store
|
||||
**/.DS_Store
|
||||
|
||||
|
||||
1
platforms/macos/Minecraft/.gitignore
vendored
Normal file
1
platforms/macos/Minecraft/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/build
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,6 +5,8 @@
|
||||
|
||||
SoundSystemAL::SoundSystemAL()
|
||||
{
|
||||
loaded = false;
|
||||
|
||||
device = alcOpenDevice(NULL);
|
||||
if (!device)
|
||||
{
|
||||
@@ -93,14 +95,14 @@ void SoundSystemAL::delete_sources()
|
||||
{
|
||||
if (loaded)
|
||||
{
|
||||
for (ALuint source : idle_sources)
|
||||
for (std::vector<ALuint>::iterator source = idle_sources.begin(); source != idle_sources.end(); source++)
|
||||
{
|
||||
alDeleteSources(1, &source);
|
||||
alDeleteSources(1, &*source);
|
||||
AL_ERROR_CHECK();
|
||||
}
|
||||
for (ALuint source : sources)
|
||||
for (std::vector<ALuint>::iterator source = sources.begin(); source != sources.end(); source++)
|
||||
{
|
||||
alDeleteSources(1, &source);
|
||||
alDeleteSources(1, &*source);
|
||||
AL_ERROR_CHECK();
|
||||
}
|
||||
}
|
||||
@@ -113,11 +115,12 @@ void SoundSystemAL::delete_buffers()
|
||||
{
|
||||
if (loaded)
|
||||
{
|
||||
for (auto &it : buffers)
|
||||
for (std::map<void *, ALuint>::iterator it = buffers.begin(); it != buffers.end(); it++)
|
||||
//for (auto &it : buffers)
|
||||
{
|
||||
if (it.second && alIsBuffer(it.second))
|
||||
if (it->second && alIsBuffer(it->second))
|
||||
{
|
||||
alDeleteBuffers(1, &it.second);
|
||||
alDeleteBuffers(1, &it->second);
|
||||
AL_ERROR_CHECK();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include <map>
|
||||
|
||||
#include "client/sound/SoundSystem.hpp"
|
||||
#include "world/phys/Vec3.hpp"
|
||||
@@ -40,12 +40,12 @@ private:
|
||||
void delete_buffers();
|
||||
ALuint get_buffer(const SoundDesc& sound);
|
||||
|
||||
ALCdevice *device = NULL;
|
||||
ALCcontext *context = NULL;
|
||||
bool loaded = false;
|
||||
ALCdevice *device;
|
||||
ALCcontext *context;
|
||||
bool loaded;
|
||||
std::vector<ALuint> sources;
|
||||
std::vector<ALuint> idle_sources;
|
||||
std::unordered_map<void *, ALuint> buffers;
|
||||
std::map<void *, ALuint> buffers;
|
||||
|
||||
Vec3 lastListenerPos;
|
||||
};
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <sys/stat.h>
|
||||
#include <cerrno>
|
||||
|
||||
#include <png.h>
|
||||
|
||||
@@ -130,10 +131,11 @@ void AppPlatform_sdl::saveScreenshot(const std::string& filename, int glWidth, i
|
||||
|
||||
// Prevent Overwriting Screenshots
|
||||
int num = 1;
|
||||
std::string file = screenshots + '/' + time + ".png";
|
||||
const std::string path = screenshots + "/";
|
||||
std::string file = path + time + ".png";
|
||||
while (access(file.c_str(), F_OK) != -1)
|
||||
{
|
||||
file = screenshots + '/' + time + '-' + std::to_string(num) + ".png";
|
||||
file = path + SSTR(time << "-" << num << ".png");
|
||||
num++;
|
||||
}
|
||||
|
||||
@@ -282,18 +284,24 @@ Texture AppPlatform_sdl::loadTexture(const std::string& path, bool b)
|
||||
SDL_RWclose(io);
|
||||
}
|
||||
|
||||
// I don't think this logic makes any sense
|
||||
// TODO: I don't think this logic makes any sense
|
||||
LogMsg("Couldn't find file: %s", path.c_str());
|
||||
return out;
|
||||
}
|
||||
|
||||
std::string AppPlatform_sdl::getOptionsFilePath() const
|
||||
{
|
||||
return _storageDir + "/options.txt";
|
||||
}
|
||||
|
||||
std::vector<std::string> AppPlatform_sdl::getOptionStrings()
|
||||
{
|
||||
// TODO: This isn't specific to SDL2. Why isn't it in an AppPlatform base class?
|
||||
std::vector<std::string> o;
|
||||
|
||||
LogMsg("Storage dir is %s", _storageDir.c_str());
|
||||
|
||||
std::ifstream ifs(_storageDir + "/options.txt");
|
||||
std::ifstream ifs(getOptionsFilePath().c_str());
|
||||
if (!ifs.is_open())
|
||||
{
|
||||
LogMsg("Warning, options.txt doesn't exist, resetting to defaults");
|
||||
@@ -325,9 +333,11 @@ std::vector<std::string> AppPlatform_sdl::getOptionStrings()
|
||||
|
||||
void AppPlatform_sdl::setOptionStrings(const std::vector<std::string>& str)
|
||||
{
|
||||
// TODO: This isn't specific to SDL2. Why isn't it in an AppPlatform base class?
|
||||
assert(str.size() % 2 == 0);
|
||||
|
||||
std::ofstream os(_storageDir + "/options.txt");
|
||||
std::ofstream os;
|
||||
os.open(getOptionsFilePath().c_str());
|
||||
if (!os.is_open())
|
||||
{
|
||||
LogMsg("Error, options.txt can't be opened");
|
||||
|
||||
@@ -16,4 +16,5 @@ public:
|
||||
|
||||
protected:
|
||||
void ensureDirectoryExists(const char* path) override;
|
||||
std::string getOptionsFilePath() const;
|
||||
};
|
||||
|
||||
@@ -130,13 +130,13 @@ Mouse::ButtonType AppPlatform_sdlbase::GetMouseButtonType(SDL_Event event)
|
||||
switch (event.button.button)
|
||||
{
|
||||
case SDL_BUTTON_LEFT:
|
||||
return Mouse::ButtonType::LEFT;
|
||||
return Mouse::LEFT;
|
||||
case SDL_BUTTON_RIGHT:
|
||||
return Mouse::ButtonType::RIGHT;
|
||||
return Mouse::RIGHT;
|
||||
case SDL_BUTTON_MIDDLE:
|
||||
return Mouse::ButtonType::MIDDLE;
|
||||
return Mouse::MIDDLE;
|
||||
default:
|
||||
return Mouse::ButtonType::NONE;
|
||||
return Mouse::NONE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,10 +147,10 @@ Mouse::ButtonState AppPlatform_sdlbase::GetMouseButtonState(SDL_Event event)
|
||||
switch (event.type)
|
||||
{
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
result = Mouse::ButtonState::DOWN;
|
||||
result = Mouse::DOWN;
|
||||
break;
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
result = Mouse::ButtonState::UP;
|
||||
result = Mouse::UP;
|
||||
break;
|
||||
case SDL_MOUSEWHEEL:
|
||||
{
|
||||
@@ -158,17 +158,17 @@ Mouse::ButtonState AppPlatform_sdlbase::GetMouseButtonState(SDL_Event event)
|
||||
if (wheelDelta > 0)
|
||||
{
|
||||
// "A positive value indicates that the wheel was rotated forward, away from the user."
|
||||
result = Mouse::ButtonState::UP;
|
||||
result = Mouse::UP;
|
||||
}
|
||||
else
|
||||
{
|
||||
// "A negative value indicates that the wheel was rotated backward, toward the user."
|
||||
result = Mouse::ButtonState::DOWN;
|
||||
result = Mouse::DOWN;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
result = Mouse::ButtonState::UP;
|
||||
result = Mouse::UP;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -180,9 +180,9 @@ Keyboard::KeyState AppPlatform_sdlbase::GetKeyState(SDL_Event event)
|
||||
switch (event.key.state)
|
||||
{
|
||||
case SDL_RELEASED:
|
||||
return Keyboard::KeyState::UP;
|
||||
return Keyboard::UP;
|
||||
case SDL_PRESSED:
|
||||
default:
|
||||
return Keyboard::KeyState::DOWN;
|
||||
return Keyboard::DOWN;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,13 +126,13 @@ static void handle_events()
|
||||
float scale = g_fPointToPixelScale;
|
||||
float x = event.motion.x * scale;
|
||||
float y = event.motion.y * scale;
|
||||
Mouse::feed(Mouse::ButtonType::NONE, Mouse::ButtonState::UP, x, y);
|
||||
Mouse::feed(Mouse::NONE, Mouse::UP, x, y);
|
||||
g_pAppPlatform->setMouseDiff(event.motion.xrel * scale, event.motion.yrel * scale);
|
||||
break;
|
||||
}
|
||||
case SDL_MOUSEWHEEL:
|
||||
{
|
||||
Mouse::feed(Mouse::ButtonType::SCROLLWHEEL, AppPlatform_sdlbase::GetMouseButtonState(event), Mouse::getX(), Mouse::getY());
|
||||
Mouse::feed(Mouse::SCROLLWHEEL, AppPlatform_sdlbase::GetMouseButtonState(event), Mouse::getX(), Mouse::getY());
|
||||
break;
|
||||
}
|
||||
case SDL_TEXTINPUT:
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
</Project>
|
||||
@@ -318,13 +318,13 @@ label_3:
|
||||
{
|
||||
switch (hr.m_hitSide)
|
||||
{
|
||||
case HitResult::eHitSide::NOHIT: break;
|
||||
case HitResult::eHitSide::MINY: dy--; break;
|
||||
case HitResult::eHitSide::MAXY: dy++; break;
|
||||
case HitResult::eHitSide::MINZ: dz--; break;
|
||||
case HitResult::eHitSide::MAXZ: dz++; break;
|
||||
case HitResult::eHitSide::MINX: dx--; break;
|
||||
case HitResult::eHitSide::MAXX: dx++; break;
|
||||
case HitResult::NOHIT: break;
|
||||
case HitResult::MINY: dy--; break;
|
||||
case HitResult::MAXY: dy++; break;
|
||||
case HitResult::MINZ: dz--; break;
|
||||
case HitResult::MAXZ: dz++; break;
|
||||
case HitResult::MINX: dx--; break;
|
||||
case HitResult::MAXX: dx++; break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -399,18 +399,18 @@ void Minecraft::tickInput()
|
||||
|
||||
if (!bIsInGUI && m_options.field_19)
|
||||
{
|
||||
if (Mouse::getEventButton() == Mouse::ButtonType::LEFT && Mouse::getEventButtonState() == Mouse::ButtonState::DOWN)
|
||||
if (Mouse::getEventButton() == Mouse::LEFT && Mouse::getEventButtonState() == Mouse::DOWN)
|
||||
{
|
||||
handleMouseClick(1);
|
||||
field_DAC = field_DA8;
|
||||
}
|
||||
if (Mouse::getEventButton() == Mouse::ButtonType::RIGHT && Mouse::getEventButtonState() == Mouse::ButtonState::DOWN)
|
||||
if (Mouse::getEventButton() == Mouse::RIGHT && Mouse::getEventButtonState() == Mouse::DOWN)
|
||||
{
|
||||
handleMouseClick(2);
|
||||
field_DAC = field_DA8;
|
||||
}
|
||||
#ifdef ENH_ALLOW_SCROLL_WHEEL
|
||||
if (Mouse::getEventButton() == Mouse::ButtonType::SCROLLWHEEL)
|
||||
if (Mouse::getEventButton() == Mouse::SCROLLWHEEL)
|
||||
{
|
||||
int slot = m_pLocalPlayer->m_pInventory->m_SelectedHotbarSlot;
|
||||
|
||||
@@ -511,7 +511,7 @@ void Minecraft::tickInput()
|
||||
|
||||
if (m_options.field_19)
|
||||
{
|
||||
if (!Mouse::isButtonDown(Mouse::ButtonType::LEFT) || bIsInGUI)
|
||||
if (!Mouse::isButtonDown(Mouse::LEFT) || bIsInGUI)
|
||||
goto label_12;
|
||||
}
|
||||
else if (Keyboard::isKeyDown(m_options.getKey(KM_DESTROY)))
|
||||
|
||||
@@ -18,7 +18,7 @@ GuiComponent::GuiComponent() : field_4 (0)
|
||||
|
||||
void GuiComponent::blit(int dx, int dy, int sx, int sy, int tw, int th, int sw, int sh)
|
||||
{
|
||||
auto& t = Tesselator::instance;
|
||||
Tesselator& t = Tesselator::instance;
|
||||
|
||||
if (!sh) sh = th;
|
||||
if (!sw) sw = tw;
|
||||
|
||||
@@ -43,7 +43,7 @@ void SelectWorldScreen::init()
|
||||
m_buttons.push_back(&m_btnBack);
|
||||
m_buttons.push_back(&m_btnDelete);
|
||||
|
||||
field_12C = Mouse::getButtonState(Mouse::ButtonType::NONE) == Mouse::ButtonState::UP;
|
||||
field_12C = Mouse::getButtonState(Mouse::NONE) == Mouse::UP;
|
||||
|
||||
m_buttonTabList.push_back(&m_btnUnknown);
|
||||
m_buttonTabList.push_back(&m_btnDelete);
|
||||
@@ -171,7 +171,7 @@ void SelectWorldScreen::render(int mouseX, int mouseY, float f)
|
||||
else
|
||||
{
|
||||
m_pWorldSelectionList->render(0, 0, f);
|
||||
field_12C = Mouse::getButtonState(Mouse::ButtonType::LEFT) == Mouse::ButtonState::UP;
|
||||
field_12C = Mouse::getButtonState(Mouse::LEFT) == Mouse::UP;
|
||||
}
|
||||
|
||||
Screen::render(mouseX, mouseY, f);
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <utility>
|
||||
#include "common/Utils.hpp"
|
||||
#include "client/renderer/VertexPT.hpp"
|
||||
#include "client/renderer/Tesselator.hpp"
|
||||
#include "GameMods.hpp"
|
||||
|
||||
@@ -52,7 +52,7 @@ bool Keyboard::isKeyDown(int keyCode)
|
||||
if (keyCode < 0 || keyCode >= KEYBOARD_STATES_SIZE)
|
||||
return false;
|
||||
|
||||
return _states[keyCode] == KeyState::DOWN;
|
||||
return _states[keyCode] == DOWN;
|
||||
}
|
||||
|
||||
void Keyboard::reset()
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
#include <stdint.h>
|
||||
|
||||
#define KEYBOARD_STATES_SIZE (256)
|
||||
|
||||
|
||||
@@ -12,18 +12,18 @@
|
||||
std::vector<MouseAction> Mouse::_inputs;
|
||||
int Mouse::_index, Mouse::_x, Mouse::_y;
|
||||
int Mouse::_xOld, Mouse::_yOld;
|
||||
Mouse::ButtonState Mouse::_buttonStates[Mouse::ButtonType::COUNT];
|
||||
Mouse::ButtonState Mouse::_buttonStates[Mouse::COUNT];
|
||||
|
||||
void Mouse::feed(ButtonType buttonType, ButtonState buttonState, int posX, int posY)
|
||||
{
|
||||
if (buttonType != ButtonType::NONE)
|
||||
if (buttonType != NONE)
|
||||
_inputs.push_back(MouseAction(buttonType, buttonState, posX, posY));
|
||||
|
||||
// Make sure button type is valid
|
||||
if (buttonType < ButtonType::COUNT)
|
||||
if (buttonType < COUNT)
|
||||
{
|
||||
// Check if we're processing a button-state update
|
||||
if (buttonType != ButtonType::NONE)
|
||||
if (buttonType != NONE)
|
||||
_buttonStates[buttonType] = buttonState;
|
||||
|
||||
_xOld = _x;
|
||||
@@ -75,8 +75,8 @@ MouseAction* Mouse::getEvent()
|
||||
|
||||
Mouse::ButtonState Mouse::getButtonState(ButtonType btn)
|
||||
{
|
||||
if (btn < ButtonType::MIN || btn >= ButtonType::COUNT)
|
||||
return ButtonState::UP;
|
||||
if (btn < MIN || btn >= COUNT)
|
||||
return UP;
|
||||
|
||||
return _buttonStates[btn];
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ private:
|
||||
static int _index;
|
||||
static int _x, _y;
|
||||
static int _xOld, _yOld;
|
||||
static ButtonState _buttonStates[Mouse::ButtonType::COUNT];
|
||||
static ButtonState _buttonStates[Mouse::COUNT];
|
||||
};
|
||||
|
||||
struct MouseAction
|
||||
@@ -67,8 +67,8 @@ struct MouseAction
|
||||
|
||||
MouseAction()
|
||||
{
|
||||
_buttonType = Mouse::ButtonType::NONE;
|
||||
_buttonState = Mouse::ButtonState::UP;
|
||||
_buttonType = Mouse::NONE;
|
||||
_buttonState = Mouse::UP;
|
||||
_posX = 0;
|
||||
_posY = 0;
|
||||
}
|
||||
@@ -84,8 +84,8 @@ struct MouseAction
|
||||
bool isButton()
|
||||
{
|
||||
return
|
||||
_buttonType == Mouse::ButtonType::LEFT ||
|
||||
_buttonType == Mouse::ButtonType::RIGHT ||
|
||||
_buttonType == Mouse::ButtonType::MIDDLE;
|
||||
_buttonType == Mouse::LEFT ||
|
||||
_buttonType == Mouse::RIGHT ||
|
||||
_buttonType == Mouse::MIDDLE;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -530,8 +530,8 @@ void GameRenderer::render(float f)
|
||||
{
|
||||
if (m_pMinecraft->m_pLocalPlayer && m_pMinecraft->m_bGrabbedMouse)
|
||||
{
|
||||
auto pMC = m_pMinecraft;
|
||||
auto delta = pMC->m_pTurnInput->getTurnDelta();
|
||||
Minecraft *pMC = m_pMinecraft;
|
||||
ITurnInput::Delta delta = pMC->m_pTurnInput->getTurnDelta();
|
||||
pMC->field_D20 = delta.x;
|
||||
pMC->field_D24 = delta.y;
|
||||
|
||||
|
||||
@@ -484,7 +484,7 @@ void LevelRenderer::render(Mob* pMob, int a, float b)
|
||||
if (!pChunk->m_bDirty)
|
||||
continue;
|
||||
|
||||
auto iter = std::find(field_88.begin(), field_88.end(), pChunk);
|
||||
std::vector<Chunk*>::iterator iter = std::find(field_88.begin(), field_88.end(), pChunk);
|
||||
if (iter != field_88.end())
|
||||
continue;
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
********************************************************************/
|
||||
|
||||
#include "RenderList.hpp"
|
||||
#include "common/Utils.hpp"
|
||||
#include "Tesselator.hpp"
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <stdint.h>
|
||||
#include <map>
|
||||
#include "compat/GL.hpp"
|
||||
#include "RenderChunk.hpp"
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <stdint.h>
|
||||
#include "common/Utils.hpp"
|
||||
|
||||
struct Texture
|
||||
{
|
||||
|
||||
@@ -13,7 +13,7 @@ bool Textures::MIPMAP = false;
|
||||
|
||||
int Textures::loadTexture(const std::string& name, bool b)
|
||||
{
|
||||
auto i = m_textures.find(name);
|
||||
std::map<std::string, GLuint>::iterator i = m_textures.find(name);
|
||||
if (i != m_textures.end())
|
||||
return i->second;
|
||||
|
||||
@@ -83,10 +83,10 @@ void Textures::clear()
|
||||
{
|
||||
// note: Textures::clear() does not touch the dynamic textures vector
|
||||
|
||||
for (auto it = m_textures.begin(); it != m_textures.end(); it++)
|
||||
for (std::map<std::string, GLuint>::iterator it = m_textures.begin(); it != m_textures.end(); it++)
|
||||
glDeleteTextures(1, &it->second);
|
||||
|
||||
for (auto it = m_textureData.begin(); it != m_textureData.end(); it++)
|
||||
for (std::map<GLuint, TextureData>::iterator it = m_textureData.begin(); it != m_textureData.end(); it++)
|
||||
delete[] it->second.textureData.m_pixels;
|
||||
|
||||
m_textures.clear();
|
||||
@@ -107,7 +107,7 @@ Textures::~Textures()
|
||||
{
|
||||
clear();
|
||||
|
||||
for (auto it = m_dynamicTextures.begin(); it != m_dynamicTextures.end(); it++)
|
||||
for (std::vector<DynamicTexture*>::iterator it = m_dynamicTextures.begin(); it != m_dynamicTextures.end(); it++)
|
||||
{
|
||||
DynamicTexture* pDynaTex = *it;
|
||||
SAFE_DELETE(pDynaTex);
|
||||
@@ -119,7 +119,7 @@ Textures::~Textures()
|
||||
void Textures::tick()
|
||||
{
|
||||
// tick dynamic textures here
|
||||
for (auto it = m_dynamicTextures.begin(); it < m_dynamicTextures.end(); it++)
|
||||
for (std::vector<DynamicTexture*>::iterator it = m_dynamicTextures.begin(); it < m_dynamicTextures.end(); it++)
|
||||
{
|
||||
DynamicTexture* pDynaTex = *it;
|
||||
|
||||
@@ -167,7 +167,7 @@ void Textures::addDynamicTexture(DynamicTexture* pTexture)
|
||||
|
||||
Texture* Textures::getTemporaryTextureData(GLuint id)
|
||||
{
|
||||
auto i = m_textureData.find(id);
|
||||
std::map<GLuint, TextureData>::iterator i = m_textureData.find(id);
|
||||
if (i == m_textureData.end())
|
||||
return nullptr;
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ void ItemRenderer::blitRect(Tesselator& t, int x, int y, int w, int h, int color
|
||||
|
||||
void ItemRenderer::blit(int dx, int dy, int sx, int sy, int tw, int th)
|
||||
{
|
||||
auto& t = Tesselator::instance;
|
||||
Tesselator& t = Tesselator::instance;
|
||||
|
||||
float ex = float(dx), ey = float(dy);
|
||||
float uw = float(tw), uh = float(th);
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <stdint.h>
|
||||
#include "common/Utils.hpp"
|
||||
|
||||
struct PCMSoundHeader
|
||||
{
|
||||
|
||||
@@ -12,12 +12,12 @@
|
||||
|
||||
void SoundRepository::add(const std::string& name, SoundDesc& sd)
|
||||
{
|
||||
auto iter = m_repo.find(name);
|
||||
std::map<std::string, std::vector<SoundDesc> >::iterator iter = m_repo.find(name);
|
||||
if (iter == m_repo.end())
|
||||
{
|
||||
std::vector<SoundDesc> sdv;
|
||||
sdv.push_back(sd);
|
||||
m_repo.insert(std::pair<std::string, std::vector<SoundDesc>>(name, sdv));
|
||||
m_repo.insert(std::pair<std::string, std::vector<SoundDesc> >(name, sdv));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -27,7 +27,7 @@ void SoundRepository::add(const std::string& name, SoundDesc& sd)
|
||||
|
||||
bool SoundRepository::get(const std::string& name, SoundDesc& sd)
|
||||
{
|
||||
auto iter = m_repo.find(name);
|
||||
std::map<std::string, std::vector<SoundDesc> >::iterator iter = m_repo.find(name);
|
||||
if (iter == m_repo.end())
|
||||
{
|
||||
printf("Couldn't find a sound with id: %s\n", name.c_str());
|
||||
|
||||
@@ -20,6 +20,6 @@ public:
|
||||
bool get(const std::string& name, SoundDesc& sd);
|
||||
|
||||
public:
|
||||
std::map<std::string, std::vector<SoundDesc>> m_repo;
|
||||
std::map<std::string, std::vector<SoundDesc> > m_repo;
|
||||
};
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
SPDX-License-Identifier: BSD-1-Clause
|
||||
********************************************************************/
|
||||
|
||||
#include <cstdint>
|
||||
#include <stdint.h>
|
||||
#include "CThread.hpp"
|
||||
#include "common/Utils.hpp"
|
||||
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
********************************************************************/
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "Mth.hpp"
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
********************************************************************/
|
||||
|
||||
#include "Random.hpp"
|
||||
#include "common/Utils.hpp"
|
||||
|
||||
/* Period parameters */
|
||||
#define N 624
|
||||
|
||||
@@ -8,8 +8,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <stdint.h>
|
||||
#include "LongHack.hpp"
|
||||
#include "common/Utils.hpp"
|
||||
|
||||
// This appears to be VERY similar to https://github.com/SethRobinson/proton/blob/master/shared/util/CRandom.h#L10
|
||||
// It turns out, RTsoft, Mojang, and the author of Game Coding Complete used the same reference implementation of
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
template<typename T>
|
||||
static bool remove(std::vector<T>& vec, const T& t)
|
||||
{
|
||||
auto iter = std::find(vec.begin(), vec.end(), t);
|
||||
typename std::vector<T>::iterator iter = std::find(vec.begin(), vec.end(), t);
|
||||
if (iter == vec.end())
|
||||
return false;
|
||||
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
{
|
||||
int removed = 0;
|
||||
|
||||
for (auto it = toRemove.begin(); it != toRemove.end(); it++)
|
||||
for (typename std::vector<T>::const_iterator it = toRemove.begin(); it != toRemove.end(); it++)
|
||||
{
|
||||
T rem = *it;
|
||||
|
||||
|
||||
@@ -21,9 +21,12 @@
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
#ifdef USE_OLD_CPP
|
||||
#define constexpr const
|
||||
#define nullptr NULL
|
||||
#define override
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
@@ -579,6 +582,9 @@ struct TilePos : Pos
|
||||
#define SAFE_DELETE(ptr) do { if (ptr) delete ptr; } while (0)
|
||||
#define SAFE_DELETE_ARRAY(ptr) do { if (ptr) delete[] ptr; } while (0)
|
||||
|
||||
#define SSTR( x ) static_cast< std::ostringstream & >( \
|
||||
( std::ostringstream() << std::dec << x ) ).str()
|
||||
|
||||
typedef uint8_t TileID;
|
||||
|
||||
// functions from Mojang
|
||||
|
||||
@@ -98,7 +98,7 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, StartGa
|
||||
|
||||
m_pLevel->m_bIsMultiplayer = true;
|
||||
|
||||
auto pLocalPlayer = new LocalPlayer(m_pMinecraft, m_pLevel, m_pMinecraft->m_pUser, m_pLevel->m_pDimension->field_50);
|
||||
LocalPlayer *pLocalPlayer = new LocalPlayer(m_pMinecraft, m_pLevel, m_pMinecraft->m_pUser, m_pLevel->m_pDimension->field_50);
|
||||
pLocalPlayer->m_guid = ((RakNet::RakPeer*)m_pServerPeer)->GetMyGUID();
|
||||
pLocalPlayer->m_EntityID = pStartGamePkt->field_C;
|
||||
|
||||
|
||||
@@ -19,7 +19,10 @@ class NetEventCallback;
|
||||
class Level;
|
||||
class LevelChunk;
|
||||
|
||||
enum ePacketType : uint8_t
|
||||
enum ePacketType
|
||||
#ifndef USE_OLD_CPP
|
||||
: uint8_t
|
||||
#endif
|
||||
{
|
||||
PACKET_LOGIN = ID_USER_PACKET_ENUM,
|
||||
PACKET_MESSAGE,
|
||||
|
||||
@@ -219,7 +219,7 @@ void RakNetInstance::runEvents(NetEventCallback* callback)
|
||||
int timeDiff = RakNet::GetTimeMS() - m_startedPingingAt;
|
||||
if (timeDiff > 1000)
|
||||
{
|
||||
for (auto it = m_servers.begin(); it != m_servers.end(); )
|
||||
for (std::vector<PingedCompatibleServer>::iterator it = m_servers.begin(); it != m_servers.end(); )
|
||||
{
|
||||
if (RakNet::GetTimeMS() - it->m_lastPinged <= 3000)
|
||||
{
|
||||
|
||||
@@ -36,7 +36,7 @@ ServerSideNetworkHandler::~ServerSideNetworkHandler()
|
||||
if (m_pLevel)
|
||||
m_pLevel->removeListener(this);
|
||||
|
||||
for (auto it = m_onlinePlayers.begin(); it != m_onlinePlayers.end(); ++it)
|
||||
for (OnlinePlayerMap::iterator it = m_onlinePlayers.begin(); it != m_onlinePlayers.end(); ++it)
|
||||
delete it->second;
|
||||
|
||||
m_onlinePlayers.clear();
|
||||
@@ -386,7 +386,7 @@ void ServerSideNetworkHandler::redistributePacket(Packet* packet, const RakNet::
|
||||
|
||||
OnlinePlayer* ServerSideNetworkHandler::getPlayerByGUID(const RakNet::RakNetGUID& guid)
|
||||
{
|
||||
auto iter = m_onlinePlayers.find(guid);
|
||||
OnlinePlayerMap::iterator iter = m_onlinePlayers.find(guid);
|
||||
if (iter == m_onlinePlayers.end())
|
||||
return nullptr;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <unordered_map>
|
||||
#include <map>
|
||||
#include "NetEventCallback.hpp"
|
||||
#include "Minecraft.hpp"
|
||||
#include "RakNetInstance.hpp"
|
||||
@@ -31,11 +31,15 @@ struct RakNetGUIDHasher
|
||||
{
|
||||
return size_t(guid.g);
|
||||
}
|
||||
bool operator()(const RakNet::RakNetGUID& guid1, const RakNet::RakNetGUID& guid2) const
|
||||
{
|
||||
return guid1 == guid2;
|
||||
}
|
||||
};
|
||||
|
||||
typedef void(ServerSideNetworkHandler::* CommandFunction)(OnlinePlayer* player, const std::vector<std::string>& parms);
|
||||
typedef std::unordered_map<std::string, CommandFunction> CommandMap;
|
||||
typedef std::unordered_map<RakNet::RakNetGUID, OnlinePlayer*, RakNetGUIDHasher> OnlinePlayerMap;
|
||||
typedef std::map<std::string, CommandFunction> CommandMap;
|
||||
typedef std::map<RakNet::RakNetGUID, OnlinePlayer*, RakNetGUIDHasher> OnlinePlayerMap;
|
||||
|
||||
class ServerSideNetworkHandler : public NetEventCallback, public LevelListener
|
||||
{
|
||||
|
||||
@@ -179,7 +179,7 @@ int Entity::move(float x, float y, float z)
|
||||
AABB aabb = m_hitbox;
|
||||
aabb.move(x_1, -1.0f, 0);
|
||||
|
||||
auto cubes = m_pLevel->getCubes(this, aabb);
|
||||
AABBVector* cubes = m_pLevel->getCubes(this, aabb);
|
||||
|
||||
if (cubes->size())
|
||||
break;
|
||||
@@ -218,7 +218,7 @@ int Entity::move(float x, float y, float z)
|
||||
AABB aabb = m_hitbox;
|
||||
aabb.move(0, -1.0f, z_1);
|
||||
|
||||
auto cubes = m_pLevel->getCubes(this, aabb);
|
||||
AABBVector* cubes = m_pLevel->getCubes(this, aabb);
|
||||
|
||||
if (cubes->size())
|
||||
break;
|
||||
@@ -437,7 +437,7 @@ label_45:
|
||||
++field_D8;
|
||||
bool bPlaySound = true;
|
||||
|
||||
auto sound = Tile::tiles[tileID]->m_pSound;
|
||||
const Tile::SoundType *sound = Tile::tiles[tileID]->m_pSound;
|
||||
if (m_pLevel->getTile(tileX, tileY + 1, tileZ) == Tile::topSnow->m_ID)
|
||||
sound = Tile::topSnow->m_pSound;
|
||||
else if (Tile::tiles[tileID]->m_pMaterial->isLiquid())
|
||||
@@ -735,7 +735,7 @@ bool Entity::isFree(float offX, float offY, float offZ)
|
||||
AABB aabb = m_hitbox;
|
||||
aabb.move(offX, offY, offZ);
|
||||
|
||||
auto pCubes = m_pLevel->getCubes(this, aabb);
|
||||
AABBVector* pCubes = m_pLevel->getCubes(this, aabb);
|
||||
if (!pCubes)
|
||||
return false;
|
||||
|
||||
@@ -748,7 +748,7 @@ bool Entity::isFree(float offX, float offY, float offZ, float expand)
|
||||
aabb.move(offX, offY, offZ);
|
||||
aabb.grow(expand, expand, expand);
|
||||
|
||||
auto pCubes = m_pLevel->getCubes(this, aabb);
|
||||
AABBVector* pCubes = m_pLevel->getCubes(this, aabb);
|
||||
if (!pCubes)
|
||||
return false;
|
||||
|
||||
@@ -1004,7 +1004,7 @@ void Entity::resetPos()
|
||||
{
|
||||
setPos(m_pos.x, m_pos.y, m_pos.z);
|
||||
|
||||
auto pCubes = m_pLevel->getCubes(this, m_hitbox);
|
||||
AABBVector* pCubes = m_pLevel->getCubes(this, m_hitbox);
|
||||
|
||||
// if we aren't inside any tiles, great!
|
||||
if (!pCubes->size())
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "world/level/Material.hpp"
|
||||
#include "world/tile/Tile.hpp"
|
||||
#include "world/item/ItemInstance.hpp"
|
||||
#include "common/Utils.hpp"
|
||||
|
||||
class Level;
|
||||
class Player;
|
||||
|
||||
@@ -617,8 +617,8 @@ void Mob::aiStep()
|
||||
AABB aabb = m_hitbox;
|
||||
aabb.grow(0.2f, 0.2f, 0.2f);
|
||||
|
||||
auto pEnts = m_pLevel->getEntities(this, aabb);
|
||||
for (auto it = pEnts->begin(); it != pEnts->end(); it++)
|
||||
EntityVector* pEnts = m_pLevel->getEntities(this, aabb);
|
||||
for (EntityVector::iterator it = pEnts->begin(); it != pEnts->end(); it++)
|
||||
{
|
||||
Entity* pEnt = *it;
|
||||
if (pEnt->isPushable())
|
||||
|
||||
@@ -167,9 +167,9 @@ void Player::aiStep()
|
||||
AABB scanAABB = m_hitbox;
|
||||
scanAABB.grow(1, 1, 1);
|
||||
|
||||
auto pEnts = m_pLevel->getEntities(this, scanAABB);
|
||||
EntityVector* pEnts = m_pLevel->getEntities(this, scanAABB);
|
||||
|
||||
for (auto it = pEnts->begin(); it != pEnts->end(); it++)
|
||||
for (EntityVector::iterator it = pEnts->begin(); it != pEnts->end(); it++)
|
||||
{
|
||||
Entity* pEnt = *it;
|
||||
if (pEnt->m_bRemoved)
|
||||
|
||||
@@ -114,7 +114,7 @@ int Inventory::getNumItems()
|
||||
|
||||
void Inventory::addCreativeItem(int itemID, int auxValue)
|
||||
{
|
||||
m_items.emplace_back(ItemInstance(itemID, 1, auxValue));
|
||||
m_items.push_back(ItemInstance(itemID, 1, auxValue));
|
||||
}
|
||||
|
||||
void Inventory::clear()
|
||||
|
||||
@@ -285,13 +285,13 @@ Material* Level::getMaterial(int x, int y, int z)
|
||||
Entity* Level::getEntity(int id)
|
||||
{
|
||||
// prioritize players first.
|
||||
for (auto it = m_players.begin(); it != m_players.end(); it++)
|
||||
for (std::vector<Player*>::iterator it = m_players.begin(); it != m_players.end(); it++)
|
||||
{
|
||||
Player* pEnt = *it;
|
||||
if (pEnt->m_EntityID == id)
|
||||
return pEnt;
|
||||
}
|
||||
for (auto it = m_entities.begin(); it != m_entities.end(); it++)
|
||||
for (std::vector<Entity*>::iterator it = m_entities.begin(); it != m_entities.end(); it++)
|
||||
{
|
||||
Entity* pEnt = *it;
|
||||
if (pEnt->m_EntityID == id)
|
||||
@@ -405,7 +405,7 @@ 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 it = m_levelListeners.begin(); it != m_levelListeners.end(); it++)
|
||||
for (std::vector<LevelListener*>::iterator it = m_levelListeners.begin(); it != m_levelListeners.end(); it++)
|
||||
{
|
||||
LevelListener* pListener = *it;
|
||||
pListener->tileBrightnessChanged(x, y, z);
|
||||
@@ -624,7 +624,7 @@ bool Level::setTileNoUpdate(int x, int y, int z, TileID tile)
|
||||
|
||||
void Level::sendTileUpdated(int x, int y, int z)
|
||||
{
|
||||
for (auto it = m_levelListeners.begin(); it != m_levelListeners.end(); it++)
|
||||
for (std::vector<LevelListener*>::iterator it = m_levelListeners.begin(); it != m_levelListeners.end(); it++)
|
||||
{
|
||||
LevelListener* pListener = *it;
|
||||
pListener->tileChanged(x, y, z);
|
||||
@@ -688,7 +688,7 @@ 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 it = m_levelListeners.begin(); it != m_levelListeners.end(); it++)
|
||||
for (std::vector<LevelListener*>::iterator it = m_levelListeners.begin(); it != m_levelListeners.end(); it++)
|
||||
{
|
||||
LevelListener* pListener = *it;
|
||||
pListener->setTilesDirty(x1, y1, z1, x2, y2, z2);
|
||||
@@ -697,7 +697,7 @@ void Level::setTilesDirty(int x1, int y1, int z1, int x2, int y2, int z2)
|
||||
|
||||
void Level::entityAdded(Entity* pEnt)
|
||||
{
|
||||
for (auto it = m_levelListeners.begin(); it != m_levelListeners.end(); it++)
|
||||
for (std::vector<LevelListener*>::iterator it = m_levelListeners.begin(); it != m_levelListeners.end(); it++)
|
||||
{
|
||||
LevelListener* pListener = *it;
|
||||
pListener->entityAdded(pEnt);
|
||||
@@ -706,7 +706,7 @@ void Level::entityAdded(Entity* pEnt)
|
||||
|
||||
void Level::entityRemoved(Entity* pEnt)
|
||||
{
|
||||
for (auto it = m_levelListeners.begin(); it != m_levelListeners.end(); it++)
|
||||
for (std::vector<LevelListener*>::iterator it = m_levelListeners.begin(); it != m_levelListeners.end(); it++)
|
||||
{
|
||||
LevelListener* pListener = *it;
|
||||
pListener->entityRemoved(pEnt);
|
||||
@@ -757,7 +757,7 @@ Entity* Level::getNearestPlayer(float x, float y, float z, float maxDist)
|
||||
float dist = -1.0f;
|
||||
Player* pPlayer = nullptr;
|
||||
|
||||
for (auto it = m_players.begin(); it != m_players.end(); it++)
|
||||
for (std::vector<Player*>::iterator it = m_players.begin(); it != m_players.end(); it++)
|
||||
{
|
||||
Player* player = *it;
|
||||
float ldist = player->distanceToSqr(x, y, z);
|
||||
@@ -1039,7 +1039,7 @@ void Level::removeAllPendingEntityRemovals()
|
||||
{
|
||||
Util::removeAll(m_entities, m_pendingEntityRemovals);
|
||||
|
||||
for (auto it = m_pendingEntityRemovals.begin(); it != m_pendingEntityRemovals.end(); it++)
|
||||
for (EntityVector::iterator it = m_pendingEntityRemovals.begin(); it != m_pendingEntityRemovals.end(); it++)
|
||||
{
|
||||
Entity* ent = *it;
|
||||
ent->removed();
|
||||
@@ -1276,7 +1276,7 @@ bool Level::isUnobstructed(AABB* aabb)
|
||||
if (entities->size() <= 0)
|
||||
return true;
|
||||
|
||||
for (auto it = entities->begin(); it != entities->end(); it++)
|
||||
for (std::vector<Entity*>::iterator it = entities->begin(); it != entities->end(); it++)
|
||||
{
|
||||
Entity* pEnt = *it;
|
||||
if (pEnt->m_bRemoved)
|
||||
@@ -1323,7 +1323,7 @@ bool Level::mayPlace(TileID tile, int x, int y, int z, bool b)
|
||||
|
||||
void Level::removeListener(LevelListener* listener)
|
||||
{
|
||||
auto iter = std::find(m_levelListeners.begin(), m_levelListeners.end(), listener);
|
||||
std::vector<LevelListener*>::iterator iter = std::find(m_levelListeners.begin(), m_levelListeners.end(), listener);
|
||||
if (iter != m_levelListeners.end())
|
||||
m_levelListeners.erase(iter);
|
||||
}
|
||||
@@ -1360,7 +1360,7 @@ void Level::tickTiles()
|
||||
{
|
||||
m_chunksToUpdate.clear();
|
||||
|
||||
for (auto it = m_players.begin(); it != m_players.end(); it++)
|
||||
for (std::vector<Player*>::iterator it = m_players.begin(); it != m_players.end(); it++)
|
||||
{
|
||||
Player* player = *it;
|
||||
|
||||
@@ -1376,7 +1376,7 @@ void Level::tickTiles()
|
||||
}
|
||||
}
|
||||
|
||||
for (auto it = m_chunksToUpdate.begin(); it != m_chunksToUpdate.end(); it++)
|
||||
for (std::set<ChunkPos>::iterator it = m_chunksToUpdate.begin(); it != m_chunksToUpdate.end(); it++)
|
||||
{
|
||||
ChunkPos pos = *it;
|
||||
LevelChunk* pChunk = getChunk(pos.x, pos.z);
|
||||
@@ -1469,7 +1469,7 @@ void Level::tick()
|
||||
{
|
||||
m_skyDarken = light;
|
||||
|
||||
for (auto it = m_levelListeners.begin(); it != m_levelListeners.end(); it++)
|
||||
for (std::vector<LevelListener*>::iterator it = m_levelListeners.begin(); it != m_levelListeners.end(); it++)
|
||||
{
|
||||
LevelListener* pListener = *it;
|
||||
pListener->skyColorChanged();
|
||||
@@ -1895,7 +1895,7 @@ void Level::addToTickNextTick(int a, int b, int c, int d, int delay)
|
||||
|
||||
void Level::takePicture(TripodCamera* pCamera, Entity* pOwner)
|
||||
{
|
||||
for (auto it = m_levelListeners.begin(); it != m_levelListeners.end(); it++)
|
||||
for (std::vector<LevelListener*>::iterator it = m_levelListeners.begin(); it != m_levelListeners.end(); it++)
|
||||
{
|
||||
LevelListener* pListener = *it;
|
||||
pListener->takePicture(pCamera, pOwner);
|
||||
@@ -1904,7 +1904,7 @@ void Level::takePicture(TripodCamera* pCamera, Entity* pOwner)
|
||||
|
||||
void Level::addParticle(const std::string& name, float a, float b, float c, float d, float e, float f)
|
||||
{
|
||||
for (auto it = m_levelListeners.begin(); it != m_levelListeners.end(); it++)
|
||||
for (std::vector<LevelListener*>::iterator it = m_levelListeners.begin(); it != m_levelListeners.end(); it++)
|
||||
{
|
||||
LevelListener* pListener = *it;
|
||||
pListener->addParticle(name, a, b, c, d, e, f);
|
||||
@@ -1913,7 +1913,7 @@ void Level::addParticle(const std::string& name, float a, float b, float c, floa
|
||||
|
||||
void Level::playSound(Entity* entity, const std::string& name, float a, float b)
|
||||
{
|
||||
for (auto it = m_levelListeners.begin(); it != m_levelListeners.end(); it++)
|
||||
for (std::vector<LevelListener*>::iterator 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);
|
||||
@@ -1922,7 +1922,7 @@ void Level::playSound(Entity* entity, const std::string& name, float a, float b)
|
||||
|
||||
void Level::playSound(float x, float y, float z, const std::string& name, float a, float b)
|
||||
{
|
||||
for (auto it = m_levelListeners.begin(); it != m_levelListeners.end(); it++)
|
||||
for (std::vector<LevelListener*>::iterator it = m_levelListeners.begin(); it != m_levelListeners.end(); it++)
|
||||
{
|
||||
LevelListener* pListener = *it;
|
||||
pListener->playSound(name, x, y, z, a, b);
|
||||
@@ -1994,7 +1994,7 @@ void Level::addEntities(const std::vector<Entity*>& entities)
|
||||
{
|
||||
m_entities.insert(m_entities.end(), entities.begin(), entities.end());
|
||||
|
||||
for (auto it = m_entities.begin(); it != m_entities.end(); it++)
|
||||
for (std::vector<Entity*>::iterator it = m_entities.begin(); it != m_entities.end(); it++)
|
||||
{
|
||||
Entity* pEnt = *it;
|
||||
entityAdded(pEnt);
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
SPDX-License-Identifier: BSD-1-Clause
|
||||
********************************************************************/
|
||||
|
||||
#include "common/Utils.hpp"
|
||||
|
||||
#pragma once
|
||||
|
||||
class Material
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include "common/Utils.hpp"
|
||||
#include "GameMods.hpp"
|
||||
class Level;
|
||||
class LevelChunk;
|
||||
|
||||
@@ -374,7 +374,7 @@ void LevelChunk::removeEntity(Entity* pEnt, int vec)
|
||||
if (vec < 0) vec = 0;
|
||||
if (vec > 7) vec = 7;
|
||||
|
||||
auto it = std::find(m_entities[vec].begin(), m_entities[vec].end(), pEnt);
|
||||
std::vector<Entity*>::iterator it = std::find(m_entities[vec].begin(), m_entities[vec].end(), pEnt);
|
||||
|
||||
if (it != m_entities[vec].end())
|
||||
m_entities[vec].erase(it);
|
||||
@@ -583,7 +583,7 @@ void LevelChunk::getEntities(Entity* pEntExclude, const AABB& aabb, std::vector<
|
||||
|
||||
for (int b = lowerBound; b <= upperBound; b++)
|
||||
{
|
||||
for (auto it = m_entities[b].begin(); it != m_entities[b].end(); it++)
|
||||
for (std::vector<Entity*>::iterator it = m_entities[b].begin(); it != m_entities[b].end(); it++)
|
||||
{
|
||||
Entity* ent = *it;
|
||||
if (ent == pEntExclude) continue;
|
||||
|
||||
@@ -69,7 +69,7 @@ inline int GetChunkHash(int x, int z)
|
||||
LevelChunk* RandomLevelSource::getChunk(int x, int z)
|
||||
{
|
||||
int hashCode = GetChunkHash(x, z);
|
||||
auto iter = m_chunks.find(hashCode);
|
||||
std::map<int, LevelChunk*>::iterator iter = m_chunks.find(hashCode);
|
||||
if (iter != m_chunks.end())
|
||||
return iter->second;
|
||||
|
||||
@@ -97,7 +97,7 @@ LevelChunk* RandomLevelSource::getChunk(int x, int z)
|
||||
LevelChunk* RandomLevelSource::getChunkDontCreate(int x, int z)
|
||||
{
|
||||
int hashCode = GetChunkHash(x, z);
|
||||
auto iter = m_chunks.find(hashCode);
|
||||
std::map<int, LevelChunk*>::iterator iter = m_chunks.find(hashCode);
|
||||
if (iter != m_chunks.end())
|
||||
return iter->second;
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
// I doubt they used C++11 (since it came out in 2011), but this is weird...
|
||||
// We'll use std::unordered_map instead.
|
||||
|
||||
#include <unordered_map>
|
||||
#include <map>
|
||||
#include "ChunkSource.hpp"
|
||||
#include "common/Utils.hpp"
|
||||
#include "world/level/levelgen/synth/PerlinNoise.hpp"
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
bool field_4;
|
||||
LargeCaveFeature m_largeCaveFeature;
|
||||
int field_9D8[1024];
|
||||
std::unordered_map<int, LevelChunk*> m_chunks;
|
||||
std::map<int, LevelChunk*> m_chunks;
|
||||
float field_19F0;
|
||||
Random m_random;
|
||||
PerlinNoise m_perlinNoise1;
|
||||
|
||||
@@ -27,7 +27,7 @@ void ChunkStorage::saveEntities(Level* a, LevelChunk* b)
|
||||
|
||||
void ChunkStorage::saveAll(Level* a, std::vector<LevelChunk*>& b)
|
||||
{
|
||||
for (auto it = b.begin(); it != b.end(); it++)
|
||||
for (std::vector<LevelChunk*>::iterator it = b.begin(); it != b.end(); it++)
|
||||
{
|
||||
save(a, *it);
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ void ExternalFileLevelStorage::tick()
|
||||
|
||||
int index = x + z * 16;
|
||||
|
||||
auto iter = m_unsavedLevelChunks.begin();
|
||||
std::list<UnsavedLevelChunk>::iterator iter = m_unsavedLevelChunks.begin();
|
||||
for (; iter != m_unsavedLevelChunks.end(); ++iter)
|
||||
{
|
||||
if (iter->m_index == index)
|
||||
@@ -140,8 +140,8 @@ void ExternalFileLevelStorage::tick()
|
||||
{
|
||||
count++;
|
||||
|
||||
auto iter = m_unsavedLevelChunks.begin();
|
||||
for (auto it2 = m_unsavedLevelChunks.begin(); it2 != m_unsavedLevelChunks.end(); ++it2)
|
||||
std::list<UnsavedLevelChunk>::iterator iter = m_unsavedLevelChunks.begin();
|
||||
for (std::list<UnsavedLevelChunk>::iterator it2 = m_unsavedLevelChunks.begin(); it2 != m_unsavedLevelChunks.end(); ++it2)
|
||||
{
|
||||
if (iter->m_foundTime > it2->m_foundTime)
|
||||
iter = it2;
|
||||
|
||||
@@ -25,7 +25,7 @@ void ParticleEngine::setLevel(Level* level)
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
#ifndef ORIGINAL_CODE
|
||||
for (auto it = m_particles[i].begin(); it != m_particles[i].end(); it++)
|
||||
for (std::vector<Particle*>::iterator it = m_particles[i].begin(); it != m_particles[i].end(); it++)
|
||||
{
|
||||
Particle* pParticle = *it;
|
||||
delete pParticle;
|
||||
@@ -168,7 +168,7 @@ void ParticleEngine::render(Entity* ent, float f)
|
||||
|
||||
t.begin();
|
||||
|
||||
for (auto it = m_particles[i].begin(); it != m_particles[i].end(); it++)
|
||||
for (std::vector<Particle*>::iterator it = m_particles[i].begin(); it != m_particles[i].end(); it++)
|
||||
{
|
||||
Particle* pParticle = *it;
|
||||
pParticle->render(t, f, x1, x2, x3, x4, x5);
|
||||
|
||||
@@ -12,14 +12,16 @@ AABB::AABB()
|
||||
{
|
||||
}
|
||||
|
||||
AABB::AABB(Vec3 _min, Vec3 _max) :
|
||||
min(_min), max(_max)
|
||||
AABB::AABB(Vec3 _min, Vec3 _max)
|
||||
{
|
||||
min = _min;
|
||||
max = _max;
|
||||
}
|
||||
|
||||
AABB::AABB(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) :
|
||||
min(minX, minY, minZ), max(maxX, maxY, maxZ)
|
||||
AABB::AABB(float minX, float minY, float minZ, float maxX, float maxY, float maxZ)
|
||||
{
|
||||
min = Vec3(minX, minY, minZ);
|
||||
max = Vec3(maxX, maxY, maxZ);
|
||||
}
|
||||
|
||||
HitResult AABB::clip(const Vec3& vec1, const Vec3& vec2)
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "common/Mth.hpp"
|
||||
// Needed for when we're missing nullptr in multiple files
|
||||
#include "common/Utils.hpp"
|
||||
|
||||
class Vec3
|
||||
{
|
||||
|
||||
@@ -736,7 +736,7 @@ void Tile::addAABBs(Level* pLevel, int x, int y, int z, const AABB* aabb, std::v
|
||||
|
||||
if (pTileAABB && pTileAABB->intersect(*aabb))
|
||||
{
|
||||
out.emplace_back(*pTileAABB);
|
||||
out.push_back(*pTileAABB);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
1
thirdparty/raknet/RakNetDefinesOverrides.h
vendored
1
thirdparty/raknet/RakNetDefinesOverrides.h
vendored
@@ -10,3 +10,4 @@
|
||||
|
||||
// USER EDITABLE FILE
|
||||
|
||||
#include "common/Utils.hpp"
|
||||
Reference in New Issue
Block a user