forked from townforge/townforge
daemon: allow negative heights for cc_get_last_update_events
this works as an index to past updates
This commit is contained in:
parent
49f8d8f99c
commit
1b2ca8ed67
@ -1194,7 +1194,7 @@ bool t_command_parser_executor::cc_get_flag(const std::vector<std::string>& args
|
||||
bool t_command_parser_executor::cc_get_last_update_events(const std::vector<std::string>& args)
|
||||
{
|
||||
bool need_height = false, need_filter = false;
|
||||
uint64_t height = 0;
|
||||
int64_t height = 0;
|
||||
bool verbose = false;
|
||||
std::string filter;
|
||||
try
|
||||
@ -1202,7 +1202,7 @@ bool t_command_parser_executor::cc_get_last_update_events(const std::vector<std:
|
||||
for (const auto &a: args)
|
||||
{
|
||||
if (need_height)
|
||||
height = boost::lexical_cast<uint64_t>(a), need_height = false;
|
||||
height = boost::lexical_cast<int64_t>(a), need_height = false;
|
||||
else if (need_filter)
|
||||
filter = a, need_filter = false;
|
||||
else if (a == "-h")
|
||||
|
@ -2825,13 +2825,38 @@ bool t_rpc_command_executor::cc_get_flag(uint32_t id, const std::string &data, b
|
||||
return true;
|
||||
}
|
||||
|
||||
bool t_rpc_command_executor::cc_get_last_update_events(uint64_t height, bool verbose, const std::string &filter)
|
||||
bool t_rpc_command_executor::cc_get_last_update_events(int64_t height, bool verbose, const std::string &filter)
|
||||
{
|
||||
cryptonote::COMMAND_RPC_CC_GET_LAST_UPDATE_EVENTS::request req;
|
||||
cryptonote::COMMAND_RPC_CC_GET_LAST_UPDATE_EVENTS::response res;
|
||||
std::string fail_message = "Unsuccessful";
|
||||
epee::json_rpc::error error_resp;
|
||||
|
||||
if (height < 0)
|
||||
{
|
||||
cryptonote::COMMAND_RPC_GET_HEIGHT::request hreq;
|
||||
cryptonote::COMMAND_RPC_GET_HEIGHT::response hres;
|
||||
if (m_is_rpc)
|
||||
{
|
||||
if (!m_rpc_client->rpc_request(hreq, hres, "/getheight", fail_message.c_str()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!m_rpc_server->on_get_height(hreq, hres) || hres.status != CORE_RPC_STATUS_OK)
|
||||
{
|
||||
tools::fail_msg_writer() << make_error(fail_message, res.status);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (hres.height > (uint64_t)(- height) * GAME_UPDATE_FREQUENCY)
|
||||
height = hres.height + height * GAME_UPDATE_FREQUENCY;
|
||||
else
|
||||
height = 0;
|
||||
}
|
||||
|
||||
req.height = height;
|
||||
if (m_is_rpc)
|
||||
{
|
||||
|
@ -180,7 +180,7 @@ public:
|
||||
bool cc_get_account(uint32_t id, const std::string &data);
|
||||
bool cc_get_city(uint32_t id, const std::string &data);
|
||||
bool cc_get_flag(uint32_t id, const std::string &data, bool get_tiles);
|
||||
bool cc_get_last_update_events(uint64_t height, bool verbose, const std::string &filter);
|
||||
bool cc_get_last_update_events(int64_t height, bool verbose, const std::string &filter);
|
||||
bool cc_date();
|
||||
bool cc_temperature(uint32_t city);
|
||||
bool cc_chat();
|
||||
|
Loading…
Reference in New Issue
Block a user