2016-12-14 17:05:34 +01:00
|
|
|
/** @file
|
|
|
|
|
*
|
|
|
|
|
* @par History
|
|
|
|
|
*/
|
|
|
|
|
|
2016-12-15 08:50:39 +01:00
|
|
|
#include "../../clib/logfacility.h"
|
2016-12-14 17:05:34 +01:00
|
|
|
#include "../globals/uvars.h"
|
|
|
|
|
#include "../realms/realm.h"
|
2018-01-29 21:55:48 +01:00
|
|
|
#include "testenv.h"
|
2024-01-10 18:29:10 +01:00
|
|
|
#include <fmt/format.h>
|
2016-12-14 17:05:34 +01:00
|
|
|
|
|
|
|
|
namespace Pol
|
|
|
|
|
{
|
|
|
|
|
namespace Testing
|
|
|
|
|
{
|
|
|
|
|
namespace
|
|
|
|
|
{
|
|
|
|
|
// This code should mirror code in drop_item_on_ground
|
|
|
|
|
void test_drop( unsigned short chrx, unsigned short chry, short chrz, unsigned short dropx,
|
2018-01-29 21:55:48 +01:00
|
|
|
unsigned short dropy, short dropz, bool exp_result, short exp_z )
|
2016-12-14 17:05:34 +01:00
|
|
|
{
|
2024-01-10 18:29:10 +01:00
|
|
|
std::string tmp = fmt::format( "POL DropHeight({},{},{},{},{},{}): Expect {}<{}: ", chrx, chry,
|
|
|
|
|
chrz, dropx, dropy, dropz, exp_result, exp_z );
|
2016-12-14 17:05:34 +01:00
|
|
|
|
|
|
|
|
short newz;
|
|
|
|
|
Multi::UMulti* multi;
|
2024-07-07 15:32:29 +02:00
|
|
|
bool result = Core::gamestate.main_realm->dropheight( Core::Pos3d( dropx, dropy, (s8)dropz ),
|
|
|
|
|
chrz, &newz, &multi );
|
2024-01-10 18:29:10 +01:00
|
|
|
tmp += fmt::format( "Got {},{}: ", result, newz );
|
2016-12-14 17:05:34 +01:00
|
|
|
if ( exp_result != result )
|
|
|
|
|
{
|
2024-01-10 18:29:10 +01:00
|
|
|
tmp += "Failure!";
|
|
|
|
|
INFO_PRINTLN( tmp );
|
2021-08-23 07:58:42 +02:00
|
|
|
UnitTest::inc_failures();
|
2016-12-14 17:05:34 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if ( result )
|
|
|
|
|
{
|
|
|
|
|
if ( newz != exp_z )
|
|
|
|
|
{
|
2024-01-10 18:29:10 +01:00
|
|
|
tmp += "Failure!";
|
|
|
|
|
INFO_PRINTLN( tmp );
|
2021-08-23 07:58:42 +02:00
|
|
|
UnitTest::inc_failures();
|
2016-12-14 17:05:34 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-08-23 07:58:42 +02:00
|
|
|
UnitTest::inc_successes();
|
2024-01-10 18:29:10 +01:00
|
|
|
INFO_PRINTLN( "{}Ok!", tmp );
|
2016-12-14 17:05:34 +01:00
|
|
|
}
|
2018-01-29 21:55:48 +01:00
|
|
|
} // namespace
|
2016-12-14 17:05:34 +01:00
|
|
|
|
|
|
|
|
void drop_test()
|
|
|
|
|
{
|
2024-01-10 18:29:10 +01:00
|
|
|
INFO_PRINTLN( "POL datafile drop tests:" );
|
2016-12-14 17:05:34 +01:00
|
|
|
// first things first. Gotta be able to drop stuff by the brit bank.
|
|
|
|
|
test_drop( 1432, 1696, 0, 1433, 1696, 0, true, 0 );
|
|
|
|
|
// in the bank, on the floor
|
|
|
|
|
test_drop( 1437, 1687, 0, 1437, 1688, 0, true, 0 );
|
|
|
|
|
|
|
|
|
|
// on a desk in LB's castle
|
|
|
|
|
test_drop( 1328, 1645, 72, 1328, 1644, 78, true, 78 );
|
|
|
|
|
|
|
|
|
|
// one of these screwy undermap caves
|
|
|
|
|
test_drop( 2564, 489, 0, 2564, 489, 0, true, 0 );
|
|
|
|
|
test_drop( 2564, 489, 42, 2564, 489, 42, false, 0 );
|
|
|
|
|
|
|
|
|
|
// a liche room
|
|
|
|
|
test_drop( 5310, 735, 0, 5310, 735, 0, true, 0 );
|
|
|
|
|
|
|
|
|
|
// a downward slope
|
|
|
|
|
test_drop( 5304, 2488, 39, 5304, 2489, 35, true, 35 );
|
|
|
|
|
|
|
|
|
|
// a ramp in an orc fort
|
|
|
|
|
test_drop( 5210, 3616, 0, 5210, 3615, 5, true, 2 );
|
|
|
|
|
}
|
2018-01-29 21:55:48 +01:00
|
|
|
} // namespace Testing
|
|
|
|
|
} // namespace Pol
|