SID_REQUIREDWORK, SID_EXTRAWORK https://github.com/HarpyWar/pvpgn/issues/72
This commit is contained in:
parent
57968d83c8
commit
1065063561
14 changed files with 156 additions and 24 deletions
|
@ -19,6 +19,6 @@ install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/var/ DESTINATION ${LOCALSTATEDIR})
|
|||
install(FILES ad000001.mng ad000001.smk ad000002.mng ad000003.mng
|
||||
ad000004.mng ad000075.mng newbie.save
|
||||
bnserver.ini bnserver-D2DV.ini bnserver-D2XP.ini bnserver-WAR3.ini
|
||||
ver-ix86-1.mpq IX86ver1.mpq PMACver1.mpq XMACver1.mpq
|
||||
ver-ix86-1.mpq IX86ver1.mpq PMACver1.mpq XMACver1.mpq IX86ExtraWork.mpq
|
||||
icons.bni icons_STAR.bni icons-WAR3.bni
|
||||
DESTINATION ${LOCALSTATEDIR}/files)
|
||||
|
|
BIN
files/IX86ExtraWork.mpq
Normal file
BIN
files/IX86ExtraWork.mpq
Normal file
Binary file not shown.
|
@ -5,16 +5,22 @@
|
|||
Licensed under the same terms as Lua itself.
|
||||
]]--
|
||||
|
||||
|
||||
-- Receive SID_READMEMORY
|
||||
function handle_client_readmemory(account, request_id, data)
|
||||
|
||||
--TRACE("Read memory request Id: " .. request_id)
|
||||
--DEBUG("Read memory request Id: " .. request_id)
|
||||
|
||||
-- display memory bytes
|
||||
DEBUG(data)
|
||||
--TRACE(data)
|
||||
|
||||
if (config.ah) then
|
||||
ah_handle_client(account, request_id, data)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- Receive SID_EXTRAWORK
|
||||
function handle_client_extrawork(account, gametype, length, data)
|
||||
--DEBUG(string.format("Received EXTRAWORK packet with GameType: %d and Length: %d (%s)", gametype, length, data))
|
||||
|
||||
end
|
||||
|
|
|
@ -16,6 +16,10 @@ function handle_user_login(account)
|
|||
gh_handle_user_login(account)
|
||||
end
|
||||
|
||||
-- send SID_REQUIREDWORK
|
||||
--api.client_requiredwork(account.name, "IX86ExtraWork.mpq")
|
||||
|
||||
|
||||
--DEBUG(account.name.." logged in")
|
||||
--return 1;
|
||||
end
|
||||
|
|
|
@ -4187,7 +4187,6 @@ namespace pvpgn
|
|||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!(rpacket = packet_create(packet_class_bnet)))
|
||||
return -1;
|
||||
|
||||
|
@ -4204,6 +4203,27 @@ namespace pvpgn
|
|||
return 0;
|
||||
}
|
||||
|
||||
extern int conn_client_requiredwork(t_connection * c, const char * filename)
|
||||
{
|
||||
t_packet * rpacket;
|
||||
|
||||
if (!c)
|
||||
{
|
||||
eventlog(eventlog_level_error, __FUNCTION__, "got NULL conn");
|
||||
return -1;
|
||||
}
|
||||
if (!(rpacket = packet_create(packet_class_bnet)))
|
||||
return -1;
|
||||
|
||||
packet_set_size(rpacket, sizeof(t_server_requiredwork));
|
||||
packet_set_type(rpacket, SERVER_REQUIREDWORK);
|
||||
packet_append_string(rpacket, filename); // filename should be "IX86ExtraWork.mpq"
|
||||
|
||||
conn_push_outqueue(c, rpacket);
|
||||
packet_del_ref(rpacket);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -466,6 +466,7 @@ namespace pvpgn
|
|||
extern t_anongame_wol_player * conn_wol_get_anongame_player(t_connection * c);
|
||||
|
||||
extern int conn_client_readmemory(t_connection * c, unsigned int request_id, unsigned int offset, unsigned int length);
|
||||
extern int conn_client_requiredwork(t_connection * c, const char * filename);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -174,6 +174,7 @@ namespace pvpgn
|
|||
static int _client_changeemailreq(t_connection * c, t_packet const *const packet);
|
||||
static int _client_getpasswordreq(t_connection * c, t_packet const *const packet);
|
||||
static int _client_claninforeq(t_connection * c, t_packet const *const packet);
|
||||
static int _client_extrawork(t_connection * c, t_packet const *const packet);
|
||||
|
||||
/* connection state connected handler table */
|
||||
static const t_htable_row bnet_htable_con[] = {
|
||||
|
@ -274,6 +275,7 @@ namespace pvpgn
|
|||
{ CLIENT_CRASHDUMP, _client_crashdump },
|
||||
{ CLIENT_SETEMAILREPLY, _client_setemailreply },
|
||||
{ CLIENT_CLANINFOREQ, _client_claninforeq },
|
||||
{ CLIENT_EXTRAWORK, _client_extrawork },
|
||||
{ CLIENT_NULL, NULL },
|
||||
{ -1, NULL }
|
||||
};
|
||||
|
@ -1376,13 +1378,13 @@ namespace pvpgn
|
|||
}
|
||||
|
||||
{
|
||||
char const *tosfile;
|
||||
char const *filename;
|
||||
|
||||
if (!(tosfile = packet_get_str_const(packet, sizeof(t_client_fileinforeq), MAX_FILENAME_STR))) {
|
||||
if (!(filename = packet_get_str_const(packet, sizeof(t_client_fileinforeq), MAX_FILENAME_STR))) {
|
||||
eventlog(eventlog_level_error, __FUNCTION__, "[%d] got bad FILEINFOREQ packet (missing or too long tosfile)", conn_get_socket(c));
|
||||
return -1;
|
||||
}
|
||||
eventlog(eventlog_level_info, __FUNCTION__, "[%d] TOS requested: \"%s\" - type = 0x%02x", conn_get_socket(c), tosfile, bn_int_get(packet->u.client_fileinforeq.type));
|
||||
eventlog(eventlog_level_info, __FUNCTION__, "[%d] file requested: \"%s\" - type = 0x%02x", conn_get_socket(c), filename, bn_int_get(packet->u.client_fileinforeq.type));
|
||||
|
||||
/* TODO: if type is TOSFILE make bnetd to send default tosfile if selected is not found */
|
||||
if ((rpacket = packet_create(packet_class_bnet))) {
|
||||
|
@ -1397,8 +1399,8 @@ namespace pvpgn
|
|||
* timestamp doesn't work correctly and starcraft
|
||||
* needs name in client locale or displays hostname
|
||||
*/
|
||||
file_to_mod_time(c, tosfile, &rpacket->u.server_fileinforeply.timestamp);
|
||||
packet_append_string(rpacket, tosfile);
|
||||
file_to_mod_time(c, filename, &rpacket->u.server_fileinforeply.timestamp);
|
||||
packet_append_string(rpacket, filename);
|
||||
conn_push_outqueue(c, rpacket);
|
||||
packet_del_ref(rpacket);
|
||||
}
|
||||
|
@ -3304,7 +3306,7 @@ namespace pvpgn
|
|||
{
|
||||
_data.push_back(packet->u.data[i]);
|
||||
}
|
||||
lua_handle_client(c, request_id, _data, luaevent_client_readmemory);
|
||||
lua_handle_client_readmemory(c, request_id, _data);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
@ -5339,6 +5341,38 @@ namespace pvpgn
|
|||
eventlog(eventlog_level_info, __FUNCTION__, "[%d] get password for account \"%s\" to email \"%s\"", conn_get_socket(c), account_get_name(account), email);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int _client_extrawork(t_connection * c, t_packet const *const packet)
|
||||
{
|
||||
t_packet *rpacket;
|
||||
|
||||
if (packet_get_size(packet) < sizeof(t_client_extrawork)) {
|
||||
eventlog(eventlog_level_error, __FUNCTION__, "[%d] got bad EXTRAWORK packet (expected %lu bytes, got %u)", conn_get_socket(c), sizeof(t_client_extrawork), packet_get_size(packet));
|
||||
return -1;
|
||||
}
|
||||
{
|
||||
short gametype;
|
||||
short length;
|
||||
char const *data;
|
||||
|
||||
gametype = bn_int_get(packet->u.client_extrawork.gametype);
|
||||
length = bn_int_get(packet->u.client_extrawork.length);
|
||||
|
||||
if (!(data = packet_get_str_const(packet, sizeof(t_client_extrawork), 1024))) {
|
||||
eventlog(eventlog_level_error, __FUNCTION__, "[%d] got bad EXTRAWORK packet (missing or too long data)", conn_get_socket(c));
|
||||
return -1;
|
||||
}
|
||||
eventlog(eventlog_level_debug, __FUNCTION__, "[%d] Received EXTRAWORK packet with GameType: %d and Length: %d (%s)", conn_get_socket(c), gametype, length, data);
|
||||
|
||||
#ifdef WITH_LUA
|
||||
lua_handle_client_extrawork(c, gametype, length, data);
|
||||
#endif
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -766,6 +766,35 @@ namespace pvpgn
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* Send SID_REQUIREDWORK packet to a client */
|
||||
extern int __client_requiredwork(lua_State* L)
|
||||
{
|
||||
const char * username;
|
||||
const char * filename;
|
||||
try
|
||||
{
|
||||
lua::stack st(L);
|
||||
// get args
|
||||
st.at(1, username);
|
||||
st.at(2, filename);
|
||||
|
||||
if (t_account * account = accountlist_find_account(username))
|
||||
{
|
||||
if (t_connection * c = account_get_conn(account))
|
||||
conn_client_requiredwork(c, filename);
|
||||
}
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
eventlog(eventlog_level_error, __FUNCTION__, e.what());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
eventlog(eventlog_level_error, __FUNCTION__, "lua exception\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Destroy client connection */
|
||||
extern int __client_kill(lua_State* L)
|
||||
{
|
||||
|
|
|
@ -54,6 +54,7 @@ namespace pvpgn
|
|||
|
||||
extern int __client_kill(lua_State* L);
|
||||
extern int __client_readmemory(lua_State* L);
|
||||
extern int __client_requiredwork(lua_State* L);
|
||||
|
||||
extern int __command_get_group(lua_State* L);
|
||||
extern int __icon_get_rank(lua_State* L);
|
||||
|
|
|
@ -144,6 +144,7 @@ namespace pvpgn
|
|||
|
||||
{ "client_kill", __client_kill },
|
||||
{ "client_readmemory", __client_readmemory },
|
||||
{ "client_requiredwork", __client_requiredwork },
|
||||
|
||||
{ "command_get_group", __command_get_group },
|
||||
{ "icon_get_rank", __icon_get_rank },
|
||||
|
@ -418,7 +419,7 @@ namespace pvpgn
|
|||
lua::transaction(vm) << lua::lookup("handle_game_list") << o_account << lua::invoke >> columns >> data << lua::end; // invoke lua function
|
||||
|
||||
// check consistency of data and columns
|
||||
if (columns.size() != data.size() || std::floor(data.size() / (columns.size()) != data.size() / columns.size()))
|
||||
if (columns.size() != data.size() || std::floor((float)(data.size() / columns.size())) != (data.size() / columns.size()))
|
||||
return result;
|
||||
|
||||
// fill map result
|
||||
|
@ -604,18 +605,10 @@ namespace pvpgn
|
|||
}
|
||||
}
|
||||
|
||||
extern void lua_handle_client(t_connection * c, int request_id, std::vector<int> data, t_luaevent_type luaevent)
|
||||
extern void lua_handle_client_readmemory(t_connection * c, int request_id, std::vector<int> data)
|
||||
{
|
||||
t_account * account;
|
||||
const char * func_name;
|
||||
switch (luaevent)
|
||||
{
|
||||
case luaevent_client_readmemory:
|
||||
func_name = "handle_client_readmemory";
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
if (!(account = conn_get_account(c)))
|
||||
|
@ -634,6 +627,29 @@ namespace pvpgn
|
|||
eventlog(eventlog_level_error, __FUNCTION__, "lua exception\n");
|
||||
}
|
||||
}
|
||||
|
||||
extern void lua_handle_client_extrawork(t_connection * c, int gametype, int length, const char * data)
|
||||
{
|
||||
t_account * account;
|
||||
const char * func_name;
|
||||
try
|
||||
{
|
||||
if (!(account = conn_get_account(c)))
|
||||
return;
|
||||
|
||||
std::map<std::string, std::string> o_account = get_account_object(account);
|
||||
|
||||
lua::transaction(vm) << lua::lookup(func_name) << o_account << gametype << length << data << lua::invoke << lua::end; // invoke lua function
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
eventlog(eventlog_level_error, __FUNCTION__, e.what());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
eventlog(eventlog_level_error, __FUNCTION__, "lua exception\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -60,8 +60,6 @@ namespace pvpgn
|
|||
luaevent_server_rehash,
|
||||
luaevent_server_mainloop,
|
||||
|
||||
luaevent_client_readmemory
|
||||
|
||||
} t_luaevent_type;
|
||||
|
||||
|
||||
|
@ -76,7 +74,9 @@ namespace pvpgn
|
|||
extern int lua_handle_user(t_connection * c, t_connection * c_dst, char const * message_text, t_luaevent_type luaevent);
|
||||
extern const char * lua_handle_user_icon(t_connection * c, const char * iconinfo);
|
||||
extern void lua_handle_server(t_luaevent_type luaevent);
|
||||
extern void lua_handle_client(t_connection * c, int request_id, std::vector<int> data, t_luaevent_type luaevent);
|
||||
|
||||
extern void lua_handle_client_readmemory(t_connection * c, int request_id, std::vector<int> data);
|
||||
extern void lua_handle_client_extrawork(t_connection * c, int gametype, int length, const char * data);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1954,6 +1954,7 @@ namespace pvpgn
|
|||
#define SERVER_FILEINFOREPLY_TYPE_TOSFILE 0x0000001a /* tos_USA.txt */
|
||||
#define SERVER_FILEINFOREPLY_TYPE_GATEWAYS 0x0000001b /* STAR bnserver.ini */
|
||||
#define SERVER_FILEINFOREPLY_TYPE_GATEWAYS_D2 0x80000004 /* D2XP bnserver-D2DV.ini */
|
||||
#define SERVER_FILEINFOREPLY_TYPE_EXTRAWORK 0x80000005 /* IX86ExtraWork.mpq */
|
||||
#define SERVER_FILEINFOREPLY_TYPE_ICONS 0x0000001d /* STAR icons_STAR.bni */
|
||||
#define SERVER_FILEINFOREPLY_UNKNOWN2 0x00000000 /* always zero */
|
||||
/******************************************************/
|
||||
|
@ -4075,6 +4076,21 @@ namespace pvpgn
|
|||
#define SERVER_MESSAGEBOX_OKCANCEL 0x00000001
|
||||
#define SERVER_MESSAGEBOX_YESNO 0x00000004
|
||||
|
||||
#define SERVER_REQUIREDWORK 0x4Cff
|
||||
typedef struct
|
||||
{
|
||||
t_bnet_header h;
|
||||
/* FileName */
|
||||
} PACKED_ATTR() t_server_requiredwork;
|
||||
|
||||
#define CLIENT_EXTRAWORK 0x4bff
|
||||
typedef struct
|
||||
{
|
||||
t_bnet_header h;
|
||||
bn_short gametype;
|
||||
bn_short length;
|
||||
/* Data */
|
||||
} PACKED_ATTR() t_client_extrawork;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -433,6 +433,8 @@ namespace pvpgn
|
|||
return "CLIENT_ADCLICK2";
|
||||
case CLIENT_READMEMORY:
|
||||
return "CLIENT_READMEMORY";
|
||||
case CLIENT_EXTRAWORK:
|
||||
return "CLIENT_EXTRAWORK";
|
||||
case CLIENT_UNKNOWN_24:
|
||||
return "CLIENT_UNKNOWN_24";
|
||||
case CLIENT_LADDERREQ:
|
||||
|
|
|
@ -369,6 +369,9 @@ namespace pvpgn
|
|||
t_server_findanongame_profile_clan server_findanongame_profile_clan;
|
||||
|
||||
t_server_messagebox server_messagebox;
|
||||
t_server_requiredwork server_requiredwork;
|
||||
t_client_extrawork client_extrawork;
|
||||
|
||||
} u;
|
||||
} t_packet;
|
||||
|
||||
|
|
Loading…
Reference in a new issue