Added --disable-item-collection command line flag, which is useful

for evaluating client/server 'disagreements'.
This commit is contained in:
hiker
2018-05-13 23:43:29 +10:00
parent af0495848a
commit d2dc99f859
3 changed files with 19 additions and 6 deletions

View File

@@ -47,6 +47,7 @@
std::vector<scene::IMesh *> ItemManager::m_item_mesh;
std::vector<scene::IMesh *> ItemManager::m_item_lowres_mesh;
std::vector<video::SColorf> ItemManager::m_glow_color;
bool ItemManager::m_disable_item_collection = false;
ItemManager * ItemManager::m_item_manager = NULL;
@@ -329,17 +330,14 @@ void ItemManager::checkItemHit(AbstractKart* kart)
// Since at this stace item detection is by far not a bottle neck,
// the original, simple and stable algorithm is left in place.
/** Disable item collection detection for debug purposes. */
if(m_disable_item_collection) return;
for(AllItemTypes::iterator i =m_all_items.begin();
i!=m_all_items.end(); i++)
{
if((!*i) || !(*i)->isAvailable()) continue;
// DEBUG: This line can be used so that the server does NOT collect
// any items, to test that the (then) incorrect client-side prediction
// is fixed correctly.
//if ((*i)->hitKart(kart->getXYZ(), kart) &&
// !NetworkConfig::get()->isServer())
// To allow inlining and avoid including kart.hpp in item.hpp,
// we pass the kart and the position separately.
if((*i)->hitKart(kart->getXYZ(), kart))

View File

@@ -50,6 +50,9 @@ private:
/** Stores all low-resolution item models. */
static std::vector<scene::IMesh *> m_item_lowres_mesh;
/** Disable item collection (for debugging purposes). */
static bool m_disable_item_collection;
protected:
/** The instance of ItemManager while a race is on. */
static ItemManager *m_item_manager;
@@ -59,6 +62,13 @@ public:
static void create();
static void destroy();
/** Disable item collection, useful to test client mispreditions or
* client/server disagreements. */
static void disableItemCollection()
{
m_disable_item_collection = true;
} // disableItemCollection
// ------------------------------------------------------------------------
/** Returns the mesh for a certain item. */
static scene::IMesh* getItemModel(ItemState::ItemType type)

View File

@@ -584,6 +584,8 @@ void cmdLineHelp()
// " --test-ai=n Use the test-ai for every n-th AI kart.\n"
// " (so n=1 means all Ais will be the test ai)\n"
// "
// " --disable-item-collection Disable item collection. Useful for\n"
// " debugging client/server item management.\n"
" --network-console Enable network console.\n"
" --wan-server=name Start a Wan server (not a playing client).\n"
" --public-server Allow direct connection to the server (without stk server)\n"
@@ -1051,6 +1053,9 @@ int handleCmdLine()
if(CommandLine::has("--network-console"))
STKHost::m_enable_console = true;
if (CommandLine::has("--disable-item-collection"))
ItemManager::disableItemCollection();
std::string server_password;
if (CommandLine::has("--server-password", &s))
{