Pol  Revision:3cfda13
testdrop.cpp
Go to the documentation of this file.
1 
6 #include <format/format.h>
7 #include "../../clib/logfacility.h"
8 #include "../globals/uvars.h"
9 #include "../realms/realm.h"
10 #include "testenv.h"
11 
12 namespace Pol
13 {
14 namespace Testing
15 {
16 namespace
17 {
18 // This code should mirror code in drop_item_on_ground
19 void test_drop( unsigned short chrx, unsigned short chry, short chrz, unsigned short dropx,
20  unsigned short dropy, short dropz, bool exp_result, short exp_z )
21 {
22  fmt::Writer tmp;
23  tmp << "POL DropHeight(" << chrx << "," << chry << "," << chrz << "," << dropx << "," << dropy
24  << "," << dropz << "): "
25  << "Expect " << exp_result << "," << exp_z << ": ";
26 
27  short newz;
28  Multi::UMulti* multi;
29  bool result = Core::gamestate.main_realm->dropheight( dropx, dropy, dropz, chrz, &newz, &multi );
30  tmp << "Got " << result << "," << newz << ": ";
31  if ( exp_result != result )
32  {
33  tmp << "Failure!\n";
34  INFO_PRINT << tmp.str();
35  inc_failures();
36  return;
37  }
38  if ( result )
39  {
40  if ( newz != exp_z )
41  {
42  tmp << "Failure!\n";
43  INFO_PRINT << tmp.str();
44  inc_failures();
45  return;
46  }
47  }
48  inc_successes();
49  INFO_PRINT << tmp.str() << "Ok!\n";
50 }
51 } // namespace
52 
53 void drop_test()
54 {
55  INFO_PRINT << "POL datafile drop tests:\n";
56  // first things first. Gotta be able to drop stuff by the brit bank.
57  test_drop( 1432, 1696, 0, 1433, 1696, 0, true, 0 );
58  // in the bank, on the floor
59  test_drop( 1437, 1687, 0, 1437, 1688, 0, true, 0 );
60 
61  // on a desk in LB's castle
62  test_drop( 1328, 1645, 72, 1328, 1644, 78, true, 78 );
63 
64  // one of these screwy undermap caves
65  test_drop( 2564, 489, 0, 2564, 489, 0, true, 0 );
66  test_drop( 2564, 489, 42, 2564, 489, 42, false, 0 );
67 
68  // a liche room
69  test_drop( 5310, 735, 0, 5310, 735, 0, true, 0 );
70 
71  // a downward slope
72  test_drop( 5304, 2488, 39, 5304, 2489, 35, true, 35 );
73 
74  // a ramp in an orc fort
75  test_drop( 5210, 3616, 0, 5210, 3615, 5, true, 2 );
76 }
77 } // namespace Testing
78 } // namespace Pol
void inc_failures()
Definition: testenv.cpp:33
void drop_test()
Definition: testdrop.cpp:53
GameState gamestate
Definition: uvars.cpp:74
bool dropheight(unsigned short dropx, unsigned short dropy, short dropz, short chrz, short *newz, Multi::UMulti **pmulti)
Definition: realmfunc.cpp:515
void inc_successes()
Definition: testenv.cpp:38
#define INFO_PRINT
Definition: logfacility.h:223
Realms::Realm * main_realm
Definition: uvars.h:162
Definition: berror.cpp:12