From 603630408789ebde5b60d7aa52914febb440d8ce Mon Sep 17 00:00:00 2001 From: iProgramInCpp Date: Tue, 8 Aug 2023 14:00:35 +0300 Subject: [PATCH] * Add preliminary raspberry pi support. Currently it appears to be using software acceleration, so sucks, but I'll be working on it. --- Makefile | 44 +++++++++++++++++++ platforms/sdl/main.cpp | 6 +-- source/client/common/Utils.hpp | 5 +++ source/client/model/Cube.cpp | 1 + .../network/ServerSideNetworkHandler.cpp | 7 ++- 5 files changed, 56 insertions(+), 7 deletions(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..a19b0ec --- /dev/null +++ b/Makefile @@ -0,0 +1,44 @@ +# ReMinecraftPE - Makefile for linux + +SRC_DIR=source +BLD_DIR=build +RAKNET_DIR=thirdparty/raknet +PLATFORM_DIR=platforms +TARGET=minecraftcpp + +CXXFLAGS=-Isource -I. -Ithirdparty/raknet -DUSE_SDL -DUSE_OPENAL -DUSE_MATH_DEFINES -DHANDLE_CHARS_SEPARATELY -O3 +LINKFLAGS=-L/opt/vc/lib/ -lpng -lpthread -lSDL2 -lGL -lopenal -lGLU + +#include everything in source/, plus certain files from platforms +SRC_FILES = $(shell find $(SRC_DIR) -type f -name '*.cpp') +PLT_FILES = $(shell find platforms/sdl platforms/openal -type f -name '*.cpp') +RKN_FILES = $(shell find $(RAKNET_DIR) -type f -name '*.cpp') +OBJ_FILES = $(patsubst $(SRC_DIR)/%,$(BLD_DIR)/s/%,$(SRC_FILES:.cpp=.o)) $(patsubst $(PLATFORM_DIR)/%,$(BLD_DIR)/p/%,$(PLT_FILES:.cpp=.o)) $(patsubst $(PLATFORM_DIR)/%,$(BLD_DIR)/r/%,$(RKN_FILES:.cpp=.o)) + +#default target. +.PHONY = all +all: program + +#link rules for the executable +$(TARGET): $(OBJ_FILES) + $(CXX) -o $@ $^ $(LINKFLAGS) + +$(BLD_DIR)/s/%.o: $(SRC_DIR)/%.cpp + @mkdir -p $(dir $@) + $(CXX) $(CXXFLAGS) -c -o $@ $< + +$(BLD_DIR)/p/%.o: $(PLATFORM_DIR)/%.cpp + @mkdir -p $(dir $@) + $(CXX) $(CXXFLAGS) -c -o $@ $< + +$(BLD_DIR)/r/%.o: $(RAKNET_DIR)/%.cpp + @mkdir -p $(dir $@) + $(CXX) $(CXXFLAGS) -c -o $@ $< + + +program: $(TARGET) + + +clean: + rm -rf $(BLD_DIR) + rm -rf minecraftcpp diff --git a/platforms/sdl/main.cpp b/platforms/sdl/main.cpp index bdd2f0e..74dde7b 100644 --- a/platforms/sdl/main.cpp +++ b/platforms/sdl/main.cpp @@ -143,16 +143,16 @@ static void calulate_gui_scale() { if (width < 400) { - Gui::InvGuiScale = 1.0; + Gui::InvGuiScale = 1.0f; } else { - Gui::InvGuiScale = 0.5; + Gui::InvGuiScale = 0.5f; } } else { - Gui::InvGuiScale = 0.25; + Gui::InvGuiScale = 0.25f; } } diff --git a/source/client/common/Utils.hpp b/source/client/common/Utils.hpp index 92d47e9..1a22a10 100644 --- a/source/client/common/Utils.hpp +++ b/source/client/common/Utils.hpp @@ -14,6 +14,11 @@ #include #include #include +#include + +#ifndef M_PI +#define M_PI (3.14159265358979) +#endif #include diff --git a/source/client/model/Cube.cpp b/source/client/model/Cube.cpp index dddae5a..5f7f232 100644 --- a/source/client/model/Cube.cpp +++ b/source/client/model/Cube.cpp @@ -7,6 +7,7 @@ ********************************************************************/ #include "Cube.hpp" +#include "client/common/Utils.hpp" float Cube::c = 180.0f / float(M_PI); diff --git a/source/client/network/ServerSideNetworkHandler.cpp b/source/client/network/ServerSideNetworkHandler.cpp index 5a03457..8d7b9e3 100644 --- a/source/client/network/ServerSideNetworkHandler.cpp +++ b/source/client/network/ServerSideNetworkHandler.cpp @@ -53,8 +53,7 @@ void ServerSideNetworkHandler::levelGenerated(Level* level) allowIncomingConnections(m_pMinecraft->m_options.m_bServerVisibleDefault); - m_onlinePlayers.insert_or_assign(m_pMinecraft->m_pLocalPlayer->m_guid, - new OnlinePlayer(m_pMinecraft->m_pLocalPlayer, m_pMinecraft->m_pLocalPlayer->m_guid)); + m_onlinePlayers[m_pMinecraft->m_pLocalPlayer->m_guid] = new OnlinePlayer(m_pMinecraft->m_pLocalPlayer, m_pMinecraft->m_pLocalPlayer->m_guid); } void ServerSideNetworkHandler::onNewClient(const RakNet::RakNetGUID& guid) @@ -105,7 +104,7 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& guid, LoginPacke pPlayer->m_guid = guid; pPlayer->m_name = std::string(packet->m_str.C_String()); - m_onlinePlayers.insert_or_assign(guid, new OnlinePlayer(pPlayer, guid)); + m_onlinePlayers[guid] = new OnlinePlayer(pPlayer, guid); StartGamePacket sgp; sgp.field_4 = m_pLevel->getSeed(); @@ -436,4 +435,4 @@ void ServerSideNetworkHandler::commandSeed(OnlinePlayer* player, const std::vect ss << "World generation seed: "; ss << m_pLevel->getSeed(); sendMessage(player, ss.str()); -} \ No newline at end of file +}