ADD: lastip

This commit is contained in:
Kolyah35
2026-03-15 20:54:28 +03:00
parent fadcf3a7d0
commit a50877af9e
7 changed files with 66 additions and 55 deletions

View File

@@ -241,6 +241,19 @@ if(PLATFORM STREQUAL "PLATFORM_GLFW")
list(APPEND CLIENT_SOURCES "src/AppPlatform_glfw.cpp") list(APPEND CLIENT_SOURCES "src/AppPlatform_glfw.cpp")
endif() 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} add_executable(${PROJECT_NAME}
${CLIENT_SOURCES} ${CLIENT_SOURCES}
"glad/src/glad.c" "glad/src/glad.c"
@@ -256,6 +269,7 @@ if(PLATFORM STREQUAL "PLATFORM_WIN32" OR PLATFORM STREQUAL "PLATFORM_GLFW")
endif() endif()
target_include_directories(${PROJECT_NAME} PUBLIC target_include_directories(${PROJECT_NAME} PUBLIC
"${CMAKE_SOURCE_DIR}/glad/include/" "${CMAKE_SOURCE_DIR}/glad/include/"
"${CMAKE_SOURCE_DIR}/src" "${CMAKE_SOURCE_DIR}/src"
@@ -264,18 +278,6 @@ target_include_directories(${PROJECT_NAME} PUBLIC
"lib/include" "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 # Client
target_compile_definitions(${PROJECT_NAME} PUBLIC "OPENGL_ES" "NO_EGL" ${PLATFORM}) 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}) target_link_libraries(${PROJECT_NAME} zlib png_shared alsoft.common OpenAL::OpenAL glfw ${EXTRA_LIBS})

View File

@@ -79,6 +79,8 @@ OptionInt keyMenuCancel("key.menu.cancel", 8);
OptionBool firstLaunch("firstLaunch", true); OptionBool firstLaunch("firstLaunch", true);
OptionString lastIp("lastip");
void Options::initTable() { void Options::initTable() {
m_options[OPTIONS_DIFFICULTY] = &difficulty; m_options[OPTIONS_DIFFICULTY] = &difficulty;
m_options[OPTIONS_HIDEGUI] = &hidegui; m_options[OPTIONS_HIDEGUI] = &hidegui;
@@ -158,6 +160,7 @@ void Options::initTable() {
m_options[OPTIONS_ALLOW_SPRINT] = &allowSprint; m_options[OPTIONS_ALLOW_SPRINT] = &allowSprint;
m_options[OPTIONS_AUTOJUMP] = &autoJump; m_options[OPTIONS_AUTOJUMP] = &autoJump;
m_options[OPTIONS_LAST_IP] = &lastIp;
} }
void Options::set(OptionId key, const std::string& value) { void Options::set(OptionId key, const std::string& value) {

View File

@@ -81,6 +81,7 @@ enum OptionId {
OPTIONS_KEY_MENU_CANCEL, OPTIONS_KEY_MENU_CANCEL,
OPTIONS_FIRST_LAUNCH, OPTIONS_FIRST_LAUNCH,
OPTIONS_LAST_IP,
// Should be last! // Should be last!
OPTIONS_COUNT OPTIONS_COUNT

View File

@@ -5,6 +5,8 @@
#include "ProgressScreen.h" #include "ProgressScreen.h"
#include "../Font.h" #include "../Font.h"
#include "../../../network/RakNetInstance.h" #include "../../../network/RakNetInstance.h"
#include "client/Options.h"
#include "client/gui/Screen.h"
#include "client/gui/components/TextBox.h" #include "client/gui/components/TextBox.h"
#include "network/ClientSideNetworkHandler.h" #include "network/ClientSideNetworkHandler.h"
@@ -31,7 +33,7 @@ void JoinByIPScreen::buttonClicked(Button* button)
minecraft->joinMultiplayerFromString(tIP.text); minecraft->joinMultiplayerFromString(tIP.text);
{ {
minecraft->options.set(OPTIONS_LAST_IP, tIP.text);
bJoin.active = false; bJoin.active = false;
bBack.active = false; bBack.active = false;
minecraft->setScreen(new ProgressScreen()); minecraft->setScreen(new ProgressScreen());
@@ -55,6 +57,7 @@ bool JoinByIPScreen::handleBackEvent(bool isDown)
void JoinByIPScreen::tick() void JoinByIPScreen::tick()
{ {
Screen::tick();
bJoin.active = !tIP.text.empty(); bJoin.active = !tIP.text.empty();
} }
@@ -78,6 +81,8 @@ void JoinByIPScreen::init()
tabButtons.push_back(&bBack); tabButtons.push_back(&bBack);
tabButtons.push_back(&bHeader); tabButtons.push_back(&bHeader);
#endif #endif
tIP.text = minecraft->options.getStringValue(OPTIONS_LAST_IP);
} }
void JoinByIPScreen::setupPositions() { void JoinByIPScreen::setupPositions() {

View File

@@ -10,12 +10,12 @@
#define TIMER_PUSH(x) PerfTimer::push(x) #define TIMER_PUSH(x) PerfTimer::push(x)
#define TIMER_POP() PerfTimer::pop() #define TIMER_POP() PerfTimer::pop()
#define TIMER_POP_PUSH(x) PerfTimer::popPush(x) #define TIMER_POP_PUSH(x) PerfTimer::popPush(x)
#elif defined(SERVER_PROFILER) // #elif defined(SERVER_PROFILER)
#include "ServerProfiler.h" // #include "ServerProfiler.h"
#define TIMER_PUSH(x) ServerProfiler::push(x) // #define TIMER_PUSH(x) ServerProfiler::push(x)
#define TIMER_POP() ServerProfiler::pop() // #define TIMER_POP() ServerProfiler::pop()
#define TIMER_POP_PUSH(x) ServerProfiler::popPush(x) // #define TIMER_POP_PUSH(x) ServerProfiler::popPush(x)
#else #else
#define TIMER_PUSH(x) ((void*)0) #define TIMER_PUSH(x) ((void*)0)
#define TIMER_POP() ((void*)0) #define TIMER_POP() ((void*)0)

View File

@@ -1,4 +1,4 @@
#include "ServerProfiler.h" // #include "ServerProfiler.h"
std::stack<ServerProfiler::Entry> ServerProfiler::stack; // std::stack<ServerProfiler::Entry> ServerProfiler::stack;
std::unordered_map<std::string, double> ServerProfiler::times; // std::unordered_map<std::string, double> ServerProfiler::times;

View File

@@ -1,43 +1,43 @@
#pragma once // #pragma once
#include <chrono> // #include <chrono>
#include <ratio> // #include <ratio>
#include <iostream> // #include <iostream>
#include <string> // #include <string>
#include <unordered_map> // #include <unordered_map>
#include <stack> // #include <stack>
namespace ServerProfiler { // namespace ServerProfiler {
using clock = std::chrono::high_resolution_clock; // using clock = std::chrono::high_resolution_clock;
struct Entry { // struct Entry {
std::string name; // std::string name;
clock::time_point start; // clock::time_point start;
}; // };
static std::stack<Entry> stack; // static std::stack<Entry> stack;
static std::unordered_map<std::string, double> times; // static std::unordered_map<std::string, double> times;
inline void push(const std::string& name) { // inline void push(const std::string& name) {
stack.push({name, clock::now()}); // stack.push({name, clock::now()});
} // }
inline void pop() { // inline void pop() {
auto end = clock::now(); // auto end = clock::now();
auto e = stack.top(); // auto e = stack.top();
stack.pop(); // stack.pop();
double dt = std::chrono::duration<double, std::micro>(end - e.start).count(); // double dt = std::chrono::duration<double, std::micro>(end - e.start).count();
times[e.name] += dt; // times[e.name] += dt;
} // }
inline void popPush(const std::string& name) { // inline void popPush(const std::string& name) {
pop(); push(name); // pop(); push(name);
} // }
inline void report() { // inline void report() {
for (auto& it : times) { // for (auto& it : times) {
std::cout << "[PROFILER] " << it.first << ": " << it.second << std::endl; // std::cout << "[PROFILER] " << it.first << ": " << it.second << std::endl;
} // }
} // }
}; // };