diff --git a/CMakeLists.txt b/CMakeLists.txt index e04f344..961f395 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -241,6 +241,19 @@ if(PLATFORM STREQUAL "PLATFORM_GLFW") list(APPEND CLIENT_SOURCES "src/AppPlatform_glfw.cpp") endif() +# Server +add_executable("${PROJECT_NAME}-server" ${SERVER_SOURCES}) + +target_compile_definitions("${PROJECT_NAME}-server" PUBLIC "STANDALONE_SERVER" "SERVER_PROFILER") + +target_include_directories("${PROJECT_NAME}-server" PUBLIC + "${CMAKE_SOURCE_DIR}/src/" + "project/lib_projects/raknet/jni/RaknetSources" +) + +target_link_libraries("${PROJECT_NAME}-server" ${CMAKE_THREAD_LIBS_INIT} png_shared) + + add_executable(${PROJECT_NAME} ${CLIENT_SOURCES} "glad/src/glad.c" @@ -256,6 +269,7 @@ if(PLATFORM STREQUAL "PLATFORM_WIN32" OR PLATFORM STREQUAL "PLATFORM_GLFW") endif() + target_include_directories(${PROJECT_NAME} PUBLIC "${CMAKE_SOURCE_DIR}/glad/include/" "${CMAKE_SOURCE_DIR}/src" @@ -264,18 +278,6 @@ target_include_directories(${PROJECT_NAME} PUBLIC "lib/include" ) -# Server -add_executable("${PROJECT_NAME}-server" ${SERVER_SOURCES}) - -target_compile_definitions("${PROJECT_NAME}-server" PUBLIC "STANDALONE_SERVER" "SERVER_PROFILER") - -target_include_directories("${PROJECT_NAME}-server" PUBLIC - "${CMAKE_SOURCE_DIR}/src/" - "project/lib_projects/raknet/jni/RaknetSources" -) - -target_link_libraries("${PROJECT_NAME}-server" ${CMAKE_THREAD_LIBS_INIT} png_shared) - # Client target_compile_definitions(${PROJECT_NAME} PUBLIC "OPENGL_ES" "NO_EGL" ${PLATFORM}) target_link_libraries(${PROJECT_NAME} zlib png_shared alsoft.common OpenAL::OpenAL glfw ${EXTRA_LIBS}) diff --git a/src/client/Options.cpp b/src/client/Options.cpp index 1598fbe..c0fcfbc 100755 --- a/src/client/Options.cpp +++ b/src/client/Options.cpp @@ -79,6 +79,8 @@ OptionInt keyMenuCancel("key.menu.cancel", 8); OptionBool firstLaunch("firstLaunch", true); +OptionString lastIp("lastip"); + void Options::initTable() { m_options[OPTIONS_DIFFICULTY] = &difficulty; m_options[OPTIONS_HIDEGUI] = &hidegui; @@ -158,6 +160,7 @@ void Options::initTable() { m_options[OPTIONS_ALLOW_SPRINT] = &allowSprint; m_options[OPTIONS_AUTOJUMP] = &autoJump; + m_options[OPTIONS_LAST_IP] = &lastIp; } void Options::set(OptionId key, const std::string& value) { diff --git a/src/client/Options.h b/src/client/Options.h index fdbdbe0..3cf2a52 100755 --- a/src/client/Options.h +++ b/src/client/Options.h @@ -81,6 +81,7 @@ enum OptionId { OPTIONS_KEY_MENU_CANCEL, OPTIONS_FIRST_LAUNCH, + OPTIONS_LAST_IP, // Should be last! OPTIONS_COUNT diff --git a/src/client/gui/screens/JoinByIPScreen.cpp b/src/client/gui/screens/JoinByIPScreen.cpp index d449ac9..47cd44a 100644 --- a/src/client/gui/screens/JoinByIPScreen.cpp +++ b/src/client/gui/screens/JoinByIPScreen.cpp @@ -5,6 +5,8 @@ #include "ProgressScreen.h" #include "../Font.h" #include "../../../network/RakNetInstance.h" +#include "client/Options.h" +#include "client/gui/Screen.h" #include "client/gui/components/TextBox.h" #include "network/ClientSideNetworkHandler.h" @@ -31,7 +33,7 @@ void JoinByIPScreen::buttonClicked(Button* button) minecraft->joinMultiplayerFromString(tIP.text); { - + minecraft->options.set(OPTIONS_LAST_IP, tIP.text); bJoin.active = false; bBack.active = false; minecraft->setScreen(new ProgressScreen()); @@ -55,6 +57,7 @@ bool JoinByIPScreen::handleBackEvent(bool isDown) void JoinByIPScreen::tick() { + Screen::tick(); bJoin.active = !tIP.text.empty(); } @@ -78,6 +81,8 @@ void JoinByIPScreen::init() tabButtons.push_back(&bBack); tabButtons.push_back(&bHeader); #endif + + tIP.text = minecraft->options.getStringValue(OPTIONS_LAST_IP); } void JoinByIPScreen::setupPositions() { diff --git a/src/util/PerfTimer.h b/src/util/PerfTimer.h index 9b00ae1..53cf3cd 100755 --- a/src/util/PerfTimer.h +++ b/src/util/PerfTimer.h @@ -10,12 +10,12 @@ #define TIMER_PUSH(x) PerfTimer::push(x) #define TIMER_POP() PerfTimer::pop() #define TIMER_POP_PUSH(x) PerfTimer::popPush(x) -#elif defined(SERVER_PROFILER) - #include "ServerProfiler.h" +// #elif defined(SERVER_PROFILER) +// #include "ServerProfiler.h" - #define TIMER_PUSH(x) ServerProfiler::push(x) - #define TIMER_POP() ServerProfiler::pop() - #define TIMER_POP_PUSH(x) ServerProfiler::popPush(x) +// #define TIMER_PUSH(x) ServerProfiler::push(x) +// #define TIMER_POP() ServerProfiler::pop() +// #define TIMER_POP_PUSH(x) ServerProfiler::popPush(x) #else #define TIMER_PUSH(x) ((void*)0) #define TIMER_POP() ((void*)0) diff --git a/src/util/ServerProfiler.cpp b/src/util/ServerProfiler.cpp index 35b1250..0fa3755 100644 --- a/src/util/ServerProfiler.cpp +++ b/src/util/ServerProfiler.cpp @@ -1,4 +1,4 @@ -#include "ServerProfiler.h" +// #include "ServerProfiler.h" -std::stack ServerProfiler::stack; -std::unordered_map ServerProfiler::times; +// std::stack ServerProfiler::stack; +// std::unordered_map ServerProfiler::times; diff --git a/src/util/ServerProfiler.h b/src/util/ServerProfiler.h index 0a8347f..ab49fa9 100644 --- a/src/util/ServerProfiler.h +++ b/src/util/ServerProfiler.h @@ -1,43 +1,43 @@ -#pragma once +// #pragma once -#include -#include -#include -#include -#include -#include +// #include +// #include +// #include +// #include +// #include +// #include -namespace ServerProfiler { - using clock = std::chrono::high_resolution_clock; +// namespace ServerProfiler { +// using clock = std::chrono::high_resolution_clock; - struct Entry { - std::string name; - clock::time_point start; - }; +// struct Entry { +// std::string name; +// clock::time_point start; +// }; - static std::stack stack; - static std::unordered_map times; +// static std::stack stack; +// static std::unordered_map times; - inline void push(const std::string& name) { - stack.push({name, clock::now()}); - } +// inline void push(const std::string& name) { +// stack.push({name, clock::now()}); +// } - inline void pop() { - auto end = clock::now(); - auto e = stack.top(); - stack.pop(); +// inline void pop() { +// auto end = clock::now(); +// auto e = stack.top(); +// stack.pop(); - double dt = std::chrono::duration(end - e.start).count(); - times[e.name] += dt; - } +// double dt = std::chrono::duration(end - e.start).count(); +// times[e.name] += dt; +// } - inline void popPush(const std::string& name) { - pop(); push(name); - } +// inline void popPush(const std::string& name) { +// pop(); push(name); +// } - inline void report() { - for (auto& it : times) { - std::cout << "[PROFILER] " << it.first << ": " << it.second << std::endl; - } - } -}; \ No newline at end of file +// inline void report() { +// for (auto& it : times) { +// std::cout << "[PROFILER] " << it.first << ": " << it.second << std::endl; +// } +// } +// }; \ No newline at end of file