Compare commits
7 Commits
8151684a07
...
64dab6c1d2
Author | SHA1 | Date |
---|---|---|
Duncan Ogilvie | 64dab6c1d2 | |
Mr_Goldberg | c231c87312 | |
Mr_Goldberg | 373801b3a4 | |
Mr_Goldberg | 05e2c3bef0 | |
Mr_Goldberg | b1986dfe38 | |
Mr_Goldberg | 5d3bbc8529 | |
Duncan Ogilvie | a76a1d48ae |
|
@ -69,6 +69,9 @@ build_windows:
|
|||
- 7za x protobuf_x86-windows-static.7z -oprotobuf_x86-windows-static
|
||||
- 7za x protobuf_x64-windows-static.7z -oprotobuf_x64-windows-static
|
||||
- 7za x sdk_standalone.7z -osdk_standalone
|
||||
- DLL_FILES="$(ls dll/*.cpp | tr "\n" " ")"; sed "s|dll/\*.cpp|$DLL_FILES|g" -i *.bat
|
||||
- DLL_FILES="$(ls dll/*.proto | tr "\n" " " | sed "s/.proto/.pb.cc/g")"; sed "s|dll/\*.cc|$DLL_FILES|g" -i *.bat
|
||||
- sed "s| /MP12 | /MP4 |g" -i *.bat
|
||||
- python generate_build_win_bat.py
|
||||
- export WINEDEBUG=-all
|
||||
- wine cmd /c build_win_release_test.bat
|
||||
|
|
|
@ -117,6 +117,7 @@ inline void reset_LastError()
|
|||
#include <sys/time.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <linux/netdevice.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
|
|
|
@ -27,6 +27,8 @@ static uint32_t upper_range_ips[MAX_BROADCASTS];
|
|||
#define HEARTBEAT_TIMEOUT 20.0
|
||||
#define USER_TIMEOUT 20.0
|
||||
|
||||
#define MAX_UDP_SIZE 16384
|
||||
|
||||
#if defined(STEAM_WIN32)
|
||||
|
||||
//windows xp support
|
||||
|
@ -215,6 +217,11 @@ static int set_socket_nonblocking(sock_t sock)
|
|||
#endif
|
||||
}
|
||||
|
||||
static bool disable_nagle(sock_t sock)
|
||||
{
|
||||
int set = 1;
|
||||
return (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char *)&set, sizeof(set)) == 0);
|
||||
}
|
||||
|
||||
static void kill_socket(sock_t sock)
|
||||
{
|
||||
|
@ -920,7 +927,7 @@ void Networking::Run()
|
|||
}
|
||||
|
||||
IP_PORT ip_port;
|
||||
char data[2048];
|
||||
char data[MAX_UDP_SIZE];
|
||||
int len;
|
||||
|
||||
PRINT_DEBUG("RECV UDP\n");
|
||||
|
@ -978,6 +985,7 @@ void Networking::Run()
|
|||
struct TCP_Socket socket;
|
||||
if (set_socket_nonblocking(sock)) {
|
||||
PRINT_DEBUG("SET NONBLOCK\n");
|
||||
disable_nagle(sock);
|
||||
socket.sock = sock;
|
||||
socket.received_data = true;
|
||||
socket.last_heartbeat_received = std::chrono::high_resolution_clock::now();
|
||||
|
@ -1031,6 +1039,7 @@ void Networking::Run()
|
|||
sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
if (is_socket_valid(sock) && set_socket_nonblocking(sock)) {
|
||||
PRINT_DEBUG("NEW SOCKET %u %u\n", sock, conn.tcp_socket_outgoing.sock);
|
||||
disable_nagle(sock);
|
||||
connect_socket(sock, conn.tcp_ip_port);
|
||||
conn.tcp_socket_outgoing.sock = sock;
|
||||
conn.tcp_socket_outgoing.last_heartbeat_received = std::chrono::high_resolution_clock::now();
|
||||
|
@ -1171,7 +1180,7 @@ bool Networking::sendTo(Common_Message *msg, bool reliable, Connection *conn)
|
|||
if (!enabled) return false;
|
||||
|
||||
size_t size = msg->ByteSizeLong();
|
||||
if (size >= 65000) reliable = true; //too big for UDP
|
||||
if (size >= MAX_UDP_SIZE) reliable = true; //too big for UDP
|
||||
|
||||
bool ret = false;
|
||||
CSteamID dest_id((uint64)msg->dest_id());
|
||||
|
|
|
@ -752,7 +752,7 @@ EResult SendMessageToConnection( HSteamNetConnection hConn, const void *pData, u
|
|||
if (connect_socket == s->connect_sockets.end()) return k_EResultInvalidParam;
|
||||
if (connect_socket->second.status == CONNECT_SOCKET_CLOSED) return k_EResultNoConnection;
|
||||
if (connect_socket->second.status == CONNECT_SOCKET_TIMEDOUT) return k_EResultNoConnection;
|
||||
if (connect_socket->second.status != CONNECT_SOCKET_CONNECTED) return k_EResultInvalidState;
|
||||
if (connect_socket->second.status != CONNECT_SOCKET_CONNECTED && connect_socket->second.status != CONNECT_SOCKET_CONNECTING) return k_EResultInvalidState;
|
||||
|
||||
Common_Message msg;
|
||||
msg.set_source_id(connect_socket->second.created_by.ConvertToUint64());
|
||||
|
@ -2084,10 +2084,16 @@ void Callback(Common_Message *msg)
|
|||
} else if (msg->networking_sockets().type() == Networking_Sockets::DATA) {
|
||||
auto connect_socket = s->connect_sockets.find(msg->networking_sockets().connection_id());
|
||||
if (connect_socket != s->connect_sockets.end()) {
|
||||
if (connect_socket->second.remote_identity.GetSteamID64() == msg->source_id() && connect_socket->second.status == CONNECT_SOCKET_CONNECTED) {
|
||||
if (connect_socket->second.remote_identity.GetSteamID64() == msg->source_id() && (connect_socket->second.status == CONNECT_SOCKET_CONNECTED)) {
|
||||
PRINT_DEBUG("Steam_Networking_Sockets: got data len %u on connection %u\n", msg->networking_sockets().data().size(), connect_socket->first);
|
||||
connect_socket->second.data.push(msg->networking_sockets());
|
||||
}
|
||||
} else {
|
||||
connect_socket = std::find_if(s->connect_sockets.begin(), s->connect_sockets.end(), [msg](const auto &in) {return in.second.remote_identity.GetSteamID64() == msg->source_id() && (in.second.status == CONNECT_SOCKET_NOT_ACCEPTED || in.second.status == CONNECT_SOCKET_CONNECTED) && in.second.remote_id == msg->networking_sockets().connection_id_from();});
|
||||
if (connect_socket != s->connect_sockets.end()) {
|
||||
PRINT_DEBUG("Steam_Networking_Sockets: got data len %u on not accepted connection %u\n", msg->networking_sockets().data().size(), connect_socket->first);
|
||||
connect_socket->second.data.push(msg->networking_sockets());
|
||||
}
|
||||
}
|
||||
} else if (msg->networking_sockets().type() == Networking_Sockets::CONNECTION_END) {
|
||||
auto connect_socket = s->connect_sockets.find(msg->networking_sockets().connection_id());
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <thread>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
|
@ -58,22 +59,23 @@ top:
|
|||
|
||||
std::cout << std::endl << "--------------Menu-------------" << std::endl << "\tappid\tname\tcommand line" << std::endl;
|
||||
|
||||
std::vector<std::string> arguments;
|
||||
std::vector<std::pair<std::string, uint32>> arguments;
|
||||
for (int i = 0; i < friend_count; ++i) {
|
||||
CSteamID id = SteamFriends()->GetFriendByIndex(i, k_EFriendFlagAll);
|
||||
const char *name = SteamFriends()->GetFriendPersonaName(id);
|
||||
const char *connect = SteamFriends()->GetFriendRichPresence( id, "connect");
|
||||
FriendGameInfo_t friend_info = {};
|
||||
SteamFriends()->GetFriendGamePlayed(id, &friend_info);
|
||||
auto appid = friend_info.m_gameID.AppID();
|
||||
|
||||
if (strlen(connect) > 0) {
|
||||
std::cout << arguments.size() << "\t" << friend_info.m_gameID.AppID() << "\t" << name << "\t" << connect << std::endl;
|
||||
arguments.push_back(connect);
|
||||
std::cout << arguments.size() << "\t" << appid << "\t" << name << "\t" << connect << std::endl;
|
||||
arguments.emplace_back(connect, appid);
|
||||
} else {
|
||||
if (friend_info.m_steamIDLobby != k_steamIDNil) {
|
||||
std::string connect = "+connect_lobby " + std::to_string(friend_info.m_steamIDLobby.ConvertToUint64());
|
||||
std::cout << arguments.size() << "\t" << friend_info.m_gameID.AppID() << "\t" << name << "\t" << connect << std::endl;
|
||||
arguments.push_back(connect);
|
||||
std::cout << arguments.size() << "\t" << appid << "\t" << name << "\t" << connect << std::endl;
|
||||
arguments.emplace_back(connect, appid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -85,24 +87,40 @@ top:
|
|||
|
||||
if (choice >= arguments.size()) goto top;
|
||||
|
||||
auto connect = arguments[choice].first;
|
||||
#ifdef _WIN32
|
||||
std::cout << "starting the game with: " << arguments[choice] << std::endl << "Please select the game exe" << std::endl;
|
||||
auto appid = arguments[choice].second;
|
||||
std::cout << "starting the game with: " << connect << std::endl;
|
||||
|
||||
OPENFILENAMEA ofn;
|
||||
char szFileName[MAX_PATH] = "";
|
||||
ZeroMemory(&ofn, sizeof(ofn));
|
||||
ofn.lStructSize = sizeof(ofn);
|
||||
ofn.hwndOwner = 0;
|
||||
ofn.lpstrFilter = "Exe Files (*.exe)\0*.exe\0All Files (*.*)\0*.*\0";
|
||||
ofn.lpstrFile = szFileName;
|
||||
ofn.nMaxFile = MAX_PATH;
|
||||
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
|
||||
ofn.lpstrDefExt = "txt";
|
||||
if(GetOpenFileNameA(&ofn))
|
||||
{
|
||||
std::string filename = szFileName;
|
||||
filename = "\"" + filename + "\" " + arguments[choice];
|
||||
char szBaseDirectory[MAX_PATH] = "";
|
||||
GetModuleFileNameA(0, szBaseDirectory, MAX_PATH);
|
||||
if (auto bs = strrchr(szBaseDirectory, '\\')) {
|
||||
*bs = '\0';
|
||||
}
|
||||
auto lobbyFile = std::string(szBaseDirectory) + "\\lobby_connect_" + std::to_string(appid) + ".txt";
|
||||
|
||||
auto readLobbyFile = [&lobbyFile]() {
|
||||
std::string data;
|
||||
std::ifstream ifs(lobbyFile);
|
||||
if (ifs.is_open())
|
||||
std::getline(ifs, data);
|
||||
return data;
|
||||
};
|
||||
|
||||
auto writeLobbyFile = [&lobbyFile](const std::string& data) {
|
||||
std::ofstream ofs(lobbyFile);
|
||||
ofs << data << std::endl;
|
||||
};
|
||||
|
||||
auto fileExists = [](const std::string& filename) {
|
||||
std::ifstream ifs(filename);
|
||||
return ifs.is_open();
|
||||
};
|
||||
|
||||
auto joinLobby = [&connect](std::string filename) {
|
||||
filename = "\"" + filename + "\" " + connect;
|
||||
std::cout << filename << std::endl;
|
||||
|
||||
STARTUPINFOA lpStartupInfo;
|
||||
PROCESS_INFORMATION lpProcessInfo;
|
||||
|
||||
|
@ -110,15 +128,38 @@ top:
|
|||
lpStartupInfo.cb = sizeof( lpStartupInfo );
|
||||
ZeroMemory( &lpProcessInfo, sizeof( lpProcessInfo ) );
|
||||
|
||||
CreateProcessA( NULL,
|
||||
auto success = !!CreateProcessA( NULL,
|
||||
const_cast<char *>(filename.c_str()), NULL, NULL,
|
||||
NULL, NULL, NULL, NULL,
|
||||
&lpStartupInfo,
|
||||
&lpProcessInfo
|
||||
);
|
||||
|
||||
CloseHandle(lpProcessInfo.hThread);
|
||||
CloseHandle(lpProcessInfo.hProcess);
|
||||
return success;
|
||||
};
|
||||
|
||||
std::string filename = readLobbyFile();
|
||||
if (filename.empty() || !fileExists(filename) || !joinLobby(filename)) {
|
||||
std::cout << "Please select the game exe" << std::endl;
|
||||
|
||||
OPENFILENAMEA ofn;
|
||||
char szFileName[MAX_PATH] = "";
|
||||
ZeroMemory(&ofn, sizeof(ofn));
|
||||
ofn.lStructSize = sizeof(ofn);
|
||||
ofn.hwndOwner = 0;
|
||||
ofn.lpstrFilter = "Exe Files (*.exe)\0*.exe\0All Files (*.*)\0*.*\0";
|
||||
ofn.lpstrFile = szFileName;
|
||||
ofn.nMaxFile = MAX_PATH;
|
||||
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
|
||||
ofn.lpstrDefExt = "exe";
|
||||
if(GetOpenFileNameA(&ofn) && joinLobby(szFileName)) {
|
||||
writeLobbyFile(szFileName);
|
||||
}
|
||||
}
|
||||
#else
|
||||
std::cout << "Please launch the game with these arguments: " << arguments[choice] << std::endl;
|
||||
std::cout << "Please launch the game with these arguments: " << connect << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -568,7 +568,7 @@ void Steam_Overlay::BuildFriendWindow(Friend const& frd, friend_window_state& st
|
|||
}
|
||||
}
|
||||
|
||||
ImGui::InputTextMultiline("##chat_history", &state.chat_history[0], state.chat_history.length(), { -1.0f, 0 }, ImGuiInputTextFlags_ReadOnly);
|
||||
ImGui::InputTextMultiline("##chat_history", &state.chat_history[0], state.chat_history.length(), { -1.0f, -2.0f * ImGui::GetFontSize() }, ImGuiInputTextFlags_ReadOnly);
|
||||
// TODO: Fix the layout of the chat line + send button.
|
||||
// It should be like this: chat input should fill the window size minus send button size (button size is fixed)
|
||||
// |------------------------------|
|
||||
|
@ -597,6 +597,7 @@ void Steam_Overlay::BuildFriendWindow(Friend const& frd, friend_window_state& st
|
|||
if (ImGui::InputText("##chat_line", state.chat_input, max_chat_len, ImGuiInputTextFlags_EnterReturnsTrue))
|
||||
{
|
||||
send_chat_msg = true;
|
||||
ImGui::SetKeyboardFocusHere(-1);
|
||||
}
|
||||
ImGui::PopItemWidth();
|
||||
|
||||
|
@ -987,7 +988,7 @@ void Steam_Overlay::Callback(Common_Message *msg)
|
|||
{
|
||||
Steam_Messages const& steam_message = msg->steam_messages();
|
||||
// Change color to cyan for friend
|
||||
friend_info->second.chat_history.append(steam_message.message()).append("\n", 1);
|
||||
friend_info->second.chat_history.append(friend_info->first.name() + ": " + steam_message.message()).append("\n", 1);
|
||||
if (!(friend_info->second.window_state & window_state_show))
|
||||
{
|
||||
friend_info->second.window_state |= window_state_need_attention;
|
||||
|
@ -1113,7 +1114,7 @@ void Steam_Overlay::RunCallbacks()
|
|||
msg.set_dest_id(friend_id);
|
||||
network->sendTo(&msg, true);
|
||||
|
||||
friend_info->second.chat_history.append(input).append("\n", 1);
|
||||
friend_info->second.chat_history.append(get_steam_client()->settings_client->get_local_name()).append(": ").append(input).append("\n", 1);
|
||||
}
|
||||
*input = 0; // Reset the input field
|
||||
friend_info->second.window_state &= ~window_state_send_message;
|
||||
|
|
Loading…
Reference in New Issue