Skip to content

Commit

Permalink
Fixed build w/o SocketW, OpenAL and AngelScript
Browse files Browse the repository at this point in the history
  • Loading branch information
ohlidalp authored and Petr Ohlídal committed Mar 14, 2023
1 parent d87a1e4 commit 00902a8
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 23 deletions.
49 changes: 30 additions & 19 deletions source/main/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,27 @@ namespace App {
// ------------------------------------------------------------------------------------------------

// Object instances
static AppContext g_app_context;
static Console g_console;
static ContentManager g_content_manager;
static OverlayWrapper* g_overlay_wrapper;
static GUIManager* g_gui_manager;
static InputEngine* g_input_engine;
static CacheSystem* g_cache_system;
static MumbleIntegration* g_mumble;
static ThreadPool* g_thread_pool;
static CameraManager* g_camera_manager;
static GfxScene g_gfx_scene;
static SoundScriptManager* g_sound_script_manager;
static LanguageEngine g_language_engine;
static ScriptEngine* g_script_engine;
static Network g_network;
static GameContext g_game_context;
static OutGauge g_out_gauge;
static DiscordRpc g_discord_rpc;
static AppContext g_app_context;
static CacheSystem* g_cache_system;
static CameraManager* g_camera_manager;
static Console g_console;
static ContentManager g_content_manager;
static DiscordRpc g_discord_rpc;
static GameContext g_game_context;
static GfxScene g_gfx_scene;
static GUIManager* g_gui_manager;
static InputEngine* g_input_engine;
static LanguageEngine g_language_engine;
static MumbleIntegration* g_mumble;
static OverlayWrapper* g_overlay_wrapper;
static OutGauge g_out_gauge;
static ScriptEngine* g_script_engine;
static SoundScriptManager* g_sound_script_manager;
static Terrain* g_sim_terrain;
static ThreadPool* g_thread_pool;
#if USE_SOCKETW

This comment has been minimized.

Copy link
@Max98

Max98 Mar 14, 2023

This is getting interesting to start on a macOS version.

This comment has been minimized.

Copy link
@ohlidalp

ohlidalp Apr 11, 2023

Author Owner

@Max98 Oh, hi! Well, get in touch with CuriousMike, he now has a PC laptop with MacOS installed. I know that OIS is a problem when porting, I didn't know about SocketW but it makes complete sense. I intend to eventually migrate to http://enet.bespin.org/ - will that improve things? Also see RigsOfRods#2983

static Network g_network;
#endif

// App
CVar* app_state;
Expand Down Expand Up @@ -265,10 +268,14 @@ GfxScene* GetGfxScene () { return &g_gfx_scene; }
SoundScriptManager* GetSoundScriptManager () { return g_sound_script_manager; }
LanguageEngine* GetLanguageEngine () { return &g_language_engine; }
ScriptEngine* GetScriptEngine () { return g_script_engine; }
Network* GetNetwork () { return &g_network; }
GameContext* GetGameContext () { return &g_game_context; }
OutGauge* GetOutGauge () { return &g_out_gauge; }
DiscordRpc* GetDiscordRpc () { return &g_discord_rpc; }
#if USE_SOCKETW
Network* GetNetwork () { return &g_network; }
#else
Network* GetNetwork () { return nullptr; }
#endif

// Factories
void CreateOverlayWrapper()
Expand Down Expand Up @@ -317,14 +324,18 @@ void CreateGfxScene()

void CreateSoundScriptManager()
{
#if USE_OPENAL
ROR_ASSERT(!g_sound_script_manager);
g_sound_script_manager = new SoundScriptManager();
#endif
}

void CreateScriptEngine()
{
#if USE_ANGELSCRIPT
ROR_ASSERT(!g_script_engine);
g_script_engine = new ScriptEngine();
#endif
}

// Cleanup
Expand Down
4 changes: 4 additions & 0 deletions source/main/gfx/GfxScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@ void GfxScene::RemoveGfxCharacter(RoR::GfxCharacter* remove_me)

void GfxScene::DrawNetLabel(Ogre::Vector3 scene_pos, float cam_dist, std::string const& nick, int colornum)
{
#if USE_SOCKETW

// this ensures that the nickname is always in a readable size
float font_size = std::max(0.6, cam_dist / 40.0);
std::string caption;
Expand Down Expand Up @@ -385,5 +387,7 @@ void GfxScene::DrawNetLabel(Ogre::Vector3 scene_pos, float cam_dist, std::string
ImVec4 text_color(color.r, color.g, color.b, 1.f);
drawlist->AddText(g->Font, g->FontSize, text_pos, ImColor(text_color), caption.c_str());
}

#endif // USE_SOCKETW
}

4 changes: 4 additions & 0 deletions source/main/gui/panels/GUI_ConsoleView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ ImVec2 ConsoleView::DrawMessage(ImVec2 cursor, Console::Message const& m)
}
}

#if USE_SOCKETW
// Add colored multiplayer username
if (m.cm_net_userid)
{
Expand All @@ -224,6 +225,9 @@ ImVec2 ConsoleView::DrawMessage(ImVec2 cursor, Console::Message const& m)
{
line = m.cm_text;
}
#else // USE_SOCKETW
line = m.cm_text;
#endif // USE_SOCKETW

// Colorize text by type
ImVec4 base_color = ImGui::GetStyle().Colors[ImGuiCol_Text];
Expand Down
4 changes: 3 additions & 1 deletion source/main/gui/panels/GUI_GameSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
#include "Language.h"
#include "SoundManager.h"

#include <alc.h>
#ifdef USE_OPENAL
# include <alc.h>
#endif

using namespace RoR;
using namespace GUI;
Expand Down
4 changes: 4 additions & 0 deletions source/main/gui/panels/GUI_MultiplayerClientList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,15 @@ using namespace Ogre;

void MpClientList::UpdateClients()
{
#if USE_SOCKETW
m_users = App::GetNetwork()->GetUserInfos();
m_users.insert(m_users.begin(), App::GetNetwork()->GetLocalUserData());
#endif // USE_SOCKETW
}

void MpClientList::Draw()
{
#if USE_SOCKETW
if (m_users.empty())
return; // UpdateClients() wasn't called yet.

Expand Down Expand Up @@ -228,6 +231,7 @@ void MpClientList::Draw()

ImGui::End();
ImGui::PopStyleColor(1); // WindowBg
#endif // USE_SOCKETW
}

bool MpClientList::DrawIcon(Ogre::TexturePtr tex, ImVec2 reference_box)
Expand Down
5 changes: 2 additions & 3 deletions source/main/gui/panels/GUI_TopMenubar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1406,17 +1406,16 @@ void TopMenubar::DrawMpUserToActorList(RoRnet::UserInfo &user)
}

// Display user in list
Ogre::ColourValue player_color;
#ifdef USE_SOCKETW
player_color = App::GetNetwork()->GetPlayerColor(user.colournum);
#endif
const Ogre::ColourValue player_color = App::GetNetwork()->GetPlayerColor(user.colournum);
ImVec4 player_gui_color(player_color.r, player_color.g, player_color.b, 1.f);
ImGui::PushStyleColor(ImGuiCol_Text, player_gui_color);
ImGui::Text("%s: %u (%s, Ver: %s, Lang: %s)",
user.username, num_actors_player,
App::GetNetwork()->UserAuthToStringShort(user).c_str(),
user.clientversion, user.language);
ImGui::PopStyleColor();
#endif // USE_SOCKETW

// Display actor list
Ogre::TexturePtr tex1 = FetchIcon("control_pause.png");
Expand Down
8 changes: 8 additions & 0 deletions source/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,10 +393,13 @@ int main(int argc, char *argv[])
// -- Network events --

case MSG_NET_CONNECT_REQUESTED:
#if USE_SOCKETW
App::GetNetwork()->StartConnecting();
#endif
break;

case MSG_NET_DISCONNECT_REQUESTED:
#if USE_SOCKETW
if (App::mp_state->getEnum<MpState>() == MpState::CONNECTED)
{
App::GetNetwork()->Disconnect();
Expand All @@ -406,6 +409,7 @@ int main(int argc, char *argv[])
App::GetGameContext()->PushMessage(Message(MSG_GUI_OPEN_MENU_REQUESTED));
}
}
#endif // USE_SOCKETW
break;

case MSG_NET_SERVER_KICK:
Expand Down Expand Up @@ -435,6 +439,7 @@ int main(int argc, char *argv[])
break;

case MSG_NET_CONNECT_SUCCESS:
#if USE_SOCKETW
App::GetGuiManager()->LoadingWindow.SetVisible(false);
App::GetNetwork()->StopConnecting();
App::mp_state->setVal((int)RoR::MpState::CONNECTED);
Expand All @@ -461,15 +466,18 @@ int main(int argc, char *argv[])
App::GetGameContext()->PushMessage(Message(MSG_SIM_LOAD_TERRN_REQUESTED, App::diag_preset_terrain->getStr()));
}
}
#endif // USE_SOCKETW
break;

case MSG_NET_CONNECT_FAILURE:
#if USE_SOCKETW
App::GetGuiManager()->LoadingWindow.SetVisible(false);
App::GetNetwork()->StopConnecting();
App::GetGameContext()->PushMessage(Message(MSG_NET_DISCONNECT_REQUESTED));
App::GetGameContext()->PushMessage(Message(MSG_GUI_OPEN_MENU_REQUESTED));
App::GetGuiManager()->ShowMessageBox(
_LC("Network", "Multiplayer: connection failed"), m.description.c_str());
#endif // USE_SOCKETW
break;

case MSG_NET_REFRESH_SERVERLIST_SUCCESS:
Expand Down
2 changes: 2 additions & 0 deletions source/main/physics/Actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ Vector3 Actor::getPosition()

void Actor::pushNetwork(char* data, int size)
{
#if USE_SOCKETW
NetUpdate update;

update.veh_state.resize(sizeof(RoRnet::VehicleState));
Expand Down Expand Up @@ -446,6 +447,7 @@ void Actor::pushNetwork(char* data, int size)
}

m_net_updates.push_back(update);
#endif // USE_SOCKETW
}

void Actor::calcNetwork()
Expand Down

0 comments on commit 00902a8

Please sign in to comment.