OGENHILL.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. /*
  2. * Seven Kingdoms: Ancient Adversaries
  3. *
  4. * Copyright 1997,1998 Enlight Software Ltd.
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. *
  19. */
  20. // Filename : OGENHILL.CPP
  21. // Description : Generate hill
  22. // Ownership : Gilbert
  23. #include <ALL.h>
  24. #include <OWORLD.h>
  25. #include <OMATRIX.h>
  26. #include <OHILLRES.h>
  27. #include <OTERRAIN.h>
  28. // ---------- begin of function World::gen_hills --------//
  29. void World::gen_hills(int terrainType)
  30. {
  31. // ------- scan each tile for an above-hill terrain tile -----//
  32. int x, y=0;
  33. char priTerrain, secTerrain, lowTerrain, highTerrain;
  34. char patternId;
  35. Location *aboveLoc, *locPtr;
  36. TerrainInfo *terrainInfo;
  37. for(y = 0; y < max_y_loc; ++y)
  38. {
  39. x = 0;
  40. if( y > 0)
  41. aboveLoc = get_loc(x, y-1);
  42. else
  43. aboveLoc = NULL;
  44. locPtr = get_loc(x,y);
  45. for( ; x < max_x_loc; ++x, ++locPtr, ++aboveLoc)
  46. {
  47. terrainInfo = terrain_res[locPtr->terrain_id];
  48. priTerrain = terrainInfo->average_type;
  49. secTerrain = terrainInfo->secondary_type;
  50. highTerrain = (priTerrain >= secTerrain ? priTerrain : secTerrain);
  51. lowTerrain = (priTerrain >= secTerrain ? secTerrain : priTerrain);
  52. if( highTerrain >= terrainType)
  53. {
  54. // BUGHERE : ignore special or extra flag
  55. patternId = terrainInfo->pattern_id;
  56. if( lowTerrain >= terrainType)
  57. {
  58. // move this terrain one square north
  59. if( y > 0)
  60. {
  61. *aboveLoc = *locPtr;
  62. // if y is max_y_loc-1, aboveLoc and locPtr looks the same
  63. // BUGHERE : repeat the same pattern below is a bug if patternId is not 0,9,10,13,14
  64. if( y == max_y_loc -1)
  65. locPtr->terrain_id = terrain_res.scan(priTerrain, secTerrain, patternId);
  66. }
  67. }
  68. else
  69. {
  70. short hillId = hill_res.scan(patternId, LOW_HILL_PRIORITY,0,0);
  71. err_when( !hillId );
  72. locPtr->set_hill(hillId);
  73. locPtr->set_fire_src(-100);
  74. //### begin alex 24/6 ###//
  75. locPtr->set_power_off();
  76. set_surr_power_off(x, y);
  77. //#### end alex 24/6 ####//
  78. if( y > 0)
  79. {
  80. aboveLoc->set_hill(hill_res.locate(patternId,
  81. hill_res[hillId]->sub_pattern_id, HIGH_HILL_PRIORITY,0));
  82. aboveLoc->set_fire_src(-100);
  83. //### begin alex 24/6 ###//
  84. aboveLoc->set_power_off();
  85. set_surr_power_off(x, y-1);
  86. //#### end alex 24/6 ####//
  87. }
  88. // set terrain type to pure teraType-1
  89. locPtr->terrain_id = terrain_res.scan(lowTerrain, lowTerrain, 0);
  90. }
  91. }
  92. }
  93. }
  94. // ------ checking exit -------//
  95. // if an exit is set, no exit is scanned in next 7 squares
  96. const int MIN_EXIT_SEPARATION = 7;
  97. int lastExit;
  98. // ------ scan for south exit, width 1 --------//
  99. #define SOUTH_PATTERN1 11
  100. #define SOUTH_PATTERN2 15
  101. #define SOUTH_PATTERN3 19
  102. #define SOUTH_PATTERN4 23
  103. #define IS_SOUTH_EXIT_PATTERN(h) (h==SOUTH_PATTERN1 || h==SOUTH_PATTERN2 || h==SOUTH_PATTERN3 || h==SOUTH_PATTERN4)
  104. #define SOUTH_LEFT_SPECIAL 'B'
  105. #define SOUTH_RIGHT_SPECIAL 'C'
  106. #define SOUTH_CENTRE_SPECIAL 'A'
  107. for( y = 1; y < max_y_loc-1; ++y)
  108. {
  109. lastExit = 0;
  110. x=0;
  111. locPtr=get_loc(x,y);
  112. for( ; x < max_x_loc-2; ++x, ++locPtr, lastExit=lastExit>0?lastExit-1:0 )
  113. {
  114. HillBlockInfo *h1, *h2, *h3;
  115. char h1p, h2p, h3p;
  116. // three hill blocks on a row are pattern 11,15,19 or 23,
  117. // block above the second block is a walkable
  118. if( !lastExit && locPtr->has_hill()
  119. && (h1=hill_res[locPtr->hill_id1()])->priority == HIGH_HILL_PRIORITY
  120. && !h1->special_flag
  121. && (h1p = h1->pattern_id)
  122. && IS_SOUTH_EXIT_PATTERN(h1p)
  123. && (locPtr+1)->has_hill()
  124. && (h2=hill_res[(locPtr+1)->hill_id1()])->priority == HIGH_HILL_PRIORITY
  125. && (h2p = h2->pattern_id)
  126. && IS_SOUTH_EXIT_PATTERN(h2p)
  127. && (locPtr+2)->has_hill()
  128. && (h3=hill_res[(locPtr+2)->hill_id1()])->priority == HIGH_HILL_PRIORITY
  129. && (h3p = h3->pattern_id)
  130. && IS_SOUTH_EXIT_PATTERN(h3p)
  131. && get_loc(x+1, y-1)->walkable() )
  132. {
  133. short hillId, terrainId;
  134. Location *loc2;
  135. // change this square
  136. if( h1p == SOUTH_PATTERN3)
  137. h1p = SOUTH_PATTERN1;
  138. else if( h1p == SOUTH_PATTERN4)
  139. h1p = SOUTH_PATTERN2;
  140. hillId = hill_res.scan(h1p, HIGH_HILL_PRIORITY, SOUTH_LEFT_SPECIAL, 0);
  141. locPtr->remove_hill();
  142. locPtr->set_hill(hillId);
  143. //### begin alex 24/6 ###//
  144. locPtr->set_power_off();
  145. set_surr_power_off(x, y);
  146. //#### end alex 24/6 ####//
  147. if((terrainId = terrain_res.scan(terrainType-1, terrainType-1,
  148. 0, 0, 1, 0 )) != 0 )
  149. locPtr->terrain_id = terrainId;
  150. err_when( locPtr->has_hill() && locPtr->walkable());
  151. // next row
  152. loc2 = get_loc(x, y+1);
  153. hillId = hill_res.locate(h1p, hill_res[hillId]->sub_pattern_id,
  154. LOW_HILL_PRIORITY, SOUTH_LEFT_SPECIAL);
  155. if( !loc2->hill_id2() )
  156. {
  157. // if the location has only one block, remove it
  158. // if the location has two block, the bottom one is replaced
  159. loc2->remove_hill();
  160. }
  161. loc2->set_hill(hillId);
  162. //### begin alex 24/6 ###//
  163. loc2->set_power_off();
  164. set_surr_power_off(x, y+1);
  165. //#### end alex 24/6 ####//
  166. if((terrainId = terrain_res.scan(terrainType-1, terrainType-1,
  167. 0, 0, 1, 0)) != 0 )
  168. loc2->terrain_id = terrainId;
  169. err_when( loc2->has_hill() && loc2->walkable());
  170. // second square
  171. loc2 = get_loc(x+1, y);
  172. loc2->remove_hill();
  173. loc2->walkable_reset();
  174. // ##### begin Gilbert 14/10 #####//
  175. //if((terrainId = terrain_res.scan(terrainType, terrainType,
  176. // 0, 0, 1, 0)) != 0 )
  177. if((terrainId = terrain_res.scan( terrainType, BOTTOM_MASK, terrainType,
  178. BOTTOM_MASK, terrainType, BOTTOM_MASK, terrainType, BOTTOM_MASK)) != 0)
  179. // ##### end Gilbert 14/10 #####//
  180. loc2->terrain_id = terrainId;
  181. err_when( loc2->has_hill() && loc2->walkable());
  182. // next row
  183. loc2 = get_loc(x+1, y+1);
  184. loc2->remove_hill();
  185. loc2->walkable_reset();
  186. if((terrainId = terrain_res.scan(terrainType, terrainType-1,
  187. SOUTH_PATTERN2, 0, 1, SOUTH_CENTRE_SPECIAL )) != 0 )
  188. loc2->terrain_id = terrainId;
  189. err_when( loc2->has_hill() && loc2->walkable());
  190. // prev row
  191. // loc2 = get_loc(x+1, y-1);
  192. // if((terrainId = terrain_res.scan(terrainType, terrainType-1,
  193. // SOUTH_PATTERN2, 0, 1, SOUTH_CENTRE_SPECIAL )) != 0 )
  194. // loc2->terrain_id = terrainId;
  195. // err_when( loc2->has_hill() && loc2->walkable());
  196. // third square
  197. loc2 = get_loc(x+2, y);
  198. if( h3p == SOUTH_PATTERN4)
  199. h3p = SOUTH_PATTERN1;
  200. if( h3p == SOUTH_PATTERN3)
  201. h3p = SOUTH_PATTERN2;
  202. hillId = hill_res.scan(h3p, HIGH_HILL_PRIORITY, SOUTH_RIGHT_SPECIAL, 0);
  203. loc2->remove_hill();
  204. loc2->set_hill(hillId);
  205. //### begin alex 24/6 ###//
  206. loc2->set_power_off();
  207. set_surr_power_off(x+2, y);
  208. //#### end alex 24/6 ####//
  209. if((terrainId = terrain_res.scan(terrainType-1, terrainType-1,
  210. 0, 0, 1, 0)) != 0 )
  211. loc2->terrain_id = terrainId;
  212. err_when( loc2->has_hill() && loc2->walkable());
  213. // next row
  214. loc2 = get_loc(x+2, y+1);
  215. hillId = hill_res.locate(h3p, hill_res[hillId]->sub_pattern_id,
  216. LOW_HILL_PRIORITY, SOUTH_RIGHT_SPECIAL);
  217. if( !loc2->hill_id2() )
  218. {
  219. // if the location has only one block, remove it
  220. // if the location has two block, the bottom one is replaced
  221. loc2->remove_hill();
  222. }
  223. loc2->set_hill(hillId);
  224. //### begin alex 24/6 ###//
  225. loc2->set_power_off();
  226. set_surr_power_off(x+2, y+1);
  227. //#### end alex 24/6 ####//
  228. if((terrainId = terrain_res.scan(terrainType-1, terrainType-1,
  229. 0, 0, 1, 0)) != 0 )
  230. loc2->terrain_id = terrainId;
  231. err_when( loc2->has_hill() && loc2->walkable());
  232. lastExit = MIN_EXIT_SEPARATION;
  233. }
  234. }
  235. }
  236. // ------ scan for north exit, width 1 --------//
  237. #define NORTH_PATTERN1 12
  238. #define NORTH_PATTERN2 16
  239. #define NORTH_PATTERN3 20
  240. #define NORTH_PATTERN4 24
  241. #define IS_NORTH_EXIT_PATTERN(h) (h==NORTH_PATTERN1 || h==NORTH_PATTERN2 || h==NORTH_PATTERN3 || h==NORTH_PATTERN4)
  242. #define NORTH_LEFT_SPECIAL 'D'
  243. #define NORTH_RIGHT_SPECIAL 'E'
  244. #define NORTH_CENTRE_SPECIAL 'F'
  245. for( y = 1; y < max_y_loc-2; ++y)
  246. {
  247. lastExit = 0;
  248. x = max_x_loc-3; // x=0;
  249. locPtr=get_loc(x,y);
  250. for( ; x >= 0; --x, --locPtr, lastExit=lastExit>0?lastExit-1:0)
  251. {
  252. HillBlockInfo *h1, *h2, *h3;
  253. char h1p, h2p, h3p;
  254. // three hill blocks on a row are pattern 12,16,20 or 24,
  255. // block below the second block is a walkable
  256. if( !lastExit && locPtr->has_hill()
  257. && (h1=hill_res[locPtr->hill_id1()])->priority == HIGH_HILL_PRIORITY
  258. && !h1->special_flag
  259. && (h1p = h1->pattern_id)
  260. && IS_NORTH_EXIT_PATTERN(h1p)
  261. && (locPtr+1)->has_hill()
  262. && (h2=hill_res[(locPtr+1)->hill_id1()])->priority == HIGH_HILL_PRIORITY
  263. && (h2p = h2->pattern_id)
  264. && IS_NORTH_EXIT_PATTERN(h2p)
  265. && (locPtr+2)->has_hill()
  266. && (h3=hill_res[(locPtr+2)->hill_id1()])->priority == HIGH_HILL_PRIORITY
  267. && (h3p = h3->pattern_id)
  268. && IS_NORTH_EXIT_PATTERN(h3p)
  269. && get_loc(x+1, y+1)->walkable() )
  270. {
  271. short hillId, terrainId;
  272. Location *loc2;
  273. // change this square
  274. if( h1p == NORTH_PATTERN4)
  275. h1p = NORTH_PATTERN1;
  276. else if( h1p == NORTH_PATTERN3)
  277. h1p = NORTH_PATTERN2;
  278. hillId = hill_res.scan(h1p, HIGH_HILL_PRIORITY, NORTH_LEFT_SPECIAL, 0);
  279. locPtr->remove_hill();
  280. locPtr->set_hill(hillId);
  281. //### begin alex 24/6 ###//
  282. locPtr->set_power_off();
  283. set_surr_power_off(x, y);
  284. //#### end alex 24/6 ####//
  285. if((terrainId = terrain_res.scan(terrainType-1, terrainType-1,
  286. 0, 0, 1, 0)) != 0 )
  287. locPtr->terrain_id = terrainId;
  288. err_when( locPtr->has_hill() && locPtr->walkable());
  289. // second square
  290. loc2 = get_loc(x+1, y);
  291. loc2->remove_hill();
  292. loc2->walkable_reset();
  293. //if((terrainId = terrain_res.scan(terrainType-1, terrainType-1,
  294. // 0, 0, 1, NORTH_CENTRE_SPECIAL)) != 0 )
  295. // loc2->terrain_id = terrainId;
  296. if((terrainId = terrain_res.scan(terrainType, terrainType-1,
  297. NORTH_PATTERN2, 0, 1, NORTH_CENTRE_SPECIAL )) != 0 )
  298. loc2->terrain_id = terrainId;
  299. err_when( loc2->has_hill() && loc2->walkable());
  300. // next row
  301. //loc2 = get_loc(x+1, y+1);
  302. //if((terrainId = terrain_res.scan(terrainType, terrainType-1,
  303. // NORTH_PATTERN2, 0, 1, NORTH_CENTRE_SPECIAL )) != 0 )
  304. // loc2->terrain_id = terrainId;
  305. //err_when( loc2->has_hill() && loc2->walkable());
  306. // third square
  307. loc2 = get_loc(x+2, y);
  308. if( h3p == NORTH_PATTERN3)
  309. h3p = NORTH_PATTERN1;
  310. if( h3p == NORTH_PATTERN4)
  311. h3p = NORTH_PATTERN2;
  312. hillId = hill_res.scan(h3p, HIGH_HILL_PRIORITY, NORTH_RIGHT_SPECIAL, 0);
  313. loc2->remove_hill();
  314. loc2->set_hill(hillId);
  315. //### begin alex 24/6 ###//
  316. loc2->set_power_off();
  317. set_surr_power_off(x+2, y);
  318. //#### end alex 24/6 ####//
  319. if((terrainId = terrain_res.scan(terrainType-1, terrainType-1,
  320. 0, 0, 1, 0)) != 0 )
  321. loc2->terrain_id = terrainId;
  322. err_when( loc2->has_hill() && loc2->walkable());
  323. lastExit = MIN_EXIT_SEPARATION;
  324. }
  325. }
  326. }
  327. // ------ scan for west exit, width 1 --------//
  328. #define WEST_PATTERN1 9
  329. #define WEST_PATTERN2 13
  330. #define WEST_PATTERN3 17
  331. #define WEST_PATTERN4 21
  332. #define IS_WEST_EXIT_PATTERN(h) (h==WEST_PATTERN1 || h==WEST_PATTERN2 || h==WEST_PATTERN3 || h==WEST_PATTERN4)
  333. #define WEST_TOP_SPECIAL 'G'
  334. #define WEST_BOTTOM_SPECIAL 'I'
  335. #define WEST_CENTRE_SPECIAL 'H'
  336. for( x = 1; x < max_x_loc-1; ++x)
  337. {
  338. lastExit = 0;
  339. for( y = 0; y < max_y_loc-4; ++y, lastExit=lastExit>0?lastExit-1:0)
  340. {
  341. locPtr=get_loc(x,y);
  342. HillBlockInfo *h1, *h2, *h3;
  343. char h1p, h2p, h3p;
  344. // three hill blocks on a row are pattern 9, 13, 17, 21
  345. // block above the second block is a walkable
  346. if( !lastExit && locPtr->has_hill()
  347. && (h1=hill_res[locPtr->hill_id1()])->priority == HIGH_HILL_PRIORITY
  348. && !h1->special_flag
  349. && (h1p = h1->pattern_id)
  350. && IS_WEST_EXIT_PATTERN(h1p)
  351. && get_loc(x,y+1)->has_hill()
  352. && get_loc(x,y+2)->has_hill()
  353. && (h2=hill_res[get_loc(x,y+2)->hill_id1()])->priority == HIGH_HILL_PRIORITY
  354. && (h2p = h2->pattern_id)
  355. && IS_WEST_EXIT_PATTERN(h2p)
  356. && get_loc(x,y+3)->has_hill()
  357. && (h3=hill_res[get_loc(x,y+3)->hill_id1()])->priority == HIGH_HILL_PRIORITY
  358. && (h3p = h3->pattern_id)
  359. && (h3p == WEST_PATTERN1 || h3p == WEST_PATTERN4)
  360. && get_loc(x+1, y+2)->walkable() )
  361. {
  362. short hillId, terrainId, hill2;
  363. Location *loc2;
  364. // change this square
  365. if( h1p == WEST_PATTERN3)
  366. h1p = WEST_PATTERN1;
  367. else if( h1p == WEST_PATTERN4)
  368. h1p = WEST_PATTERN2;
  369. hillId = hill_res.scan(h1p, HIGH_HILL_PRIORITY, WEST_TOP_SPECIAL, 0);
  370. hill2 = locPtr->hill_id2();
  371. locPtr->remove_hill();
  372. locPtr->set_hill(hillId);
  373. //### begin alex 24/6 ###//
  374. locPtr->set_power_off();
  375. set_surr_power_off(x, y);
  376. //#### end alex 24/6 ####//
  377. if( hill2 )
  378. locPtr->set_hill(hill2);
  379. err_when( locPtr->has_hill() && locPtr->walkable());
  380. // next row
  381. loc2 = get_loc(x, y+1);
  382. hillId = hill_res.locate(h1p, hill_res[hillId]->sub_pattern_id,
  383. LOW_HILL_PRIORITY, WEST_TOP_SPECIAL);
  384. loc2->remove_hill();
  385. loc2->set_hill(hillId);
  386. //### begin alex 24/6 ###//
  387. loc2->set_power_off();
  388. set_surr_power_off(x, y+1);
  389. //#### end alex 24/6 ####//
  390. if((terrainId = terrain_res.scan(terrainType-1, terrainType-1,
  391. 0, 0, 1, 0)) != 0 )
  392. loc2->terrain_id = terrainId;
  393. err_when( loc2->has_hill() && loc2->walkable());
  394. // third row
  395. loc2 = get_loc(x, y+2);
  396. loc2->remove_hill();
  397. loc2->walkable_reset();
  398. //if((terrainId = terrain_res.scan(terrainType-1, terrainType-1,
  399. // 0, 0, 1, WEST_CENTRE_SPECIAL)) != 0 )
  400. // loc2->terrain_id = terrainId;
  401. if((terrainId = terrain_res.scan(terrainType, terrainType-1,
  402. WEST_PATTERN2, 0, 1, WEST_CENTRE_SPECIAL )) != 0 )
  403. loc2->terrain_id = terrainId;
  404. err_when( loc2->has_hill() && loc2->walkable());
  405. // next column
  406. //loc2 = get_loc(x+1, y+2);
  407. //if((terrainId = terrain_res.scan(terrainType, terrainType-1,
  408. // WEST_PATTERN2, 0, 1, WEST_CENTRE_SPECIAL )) != 0 )
  409. // loc2->terrain_id = terrainId;
  410. //err_when( loc2->has_hill() && loc2->walkable());
  411. // fourth row
  412. loc2 = get_loc(x, y+3);
  413. if( h3p == WEST_PATTERN4)
  414. h3p = WEST_PATTERN1;
  415. if( h3p == WEST_PATTERN3)
  416. h3p = WEST_PATTERN2;
  417. hillId = hill_res.scan(h3p, HIGH_HILL_PRIORITY, WEST_BOTTOM_SPECIAL, 0);
  418. loc2->remove_hill();
  419. loc2->set_hill(hillId);
  420. //### begin alex 24/6 ###//
  421. loc2->set_power_off();
  422. set_surr_power_off(x, y+3);
  423. //#### end alex 24/6 ####//
  424. if((terrainId = terrain_res.scan(terrainType-1, terrainType-1,
  425. 0, 0, 1, 0 )) != 0 )
  426. loc2->terrain_id = terrainId;
  427. err_when( loc2->has_hill() && loc2->walkable());
  428. // next row
  429. loc2 = get_loc(x, y+4);
  430. hillId = hill_res.locate(h3p, hill_res[hillId]->sub_pattern_id,
  431. LOW_HILL_PRIORITY, WEST_BOTTOM_SPECIAL);
  432. loc2->set_hill(hillId);
  433. //### begin alex 24/6 ###//
  434. loc2->set_power_off();
  435. set_surr_power_off(x, y+4);
  436. //#### end alex 24/6 ####//
  437. if((terrainId = terrain_res.scan(terrainType-1, terrainType-1,
  438. 0, 0, 1, 0)) != 0 )
  439. loc2->terrain_id = terrainId;
  440. err_when( loc2->has_hill() && loc2->walkable());
  441. lastExit = MIN_EXIT_SEPARATION;
  442. }
  443. }
  444. }
  445. // ------ scan for east exit, width 1 --------//
  446. #define EAST_PATTERN1 10
  447. #define EAST_PATTERN2 14
  448. #define EAST_PATTERN3 18
  449. #define EAST_PATTERN4 22
  450. #define IS_EAST_EXIT_PATTERN(h) (h==EAST_PATTERN1 || h==EAST_PATTERN2 || h==EAST_PATTERN3 || h==EAST_PATTERN4)
  451. #define EAST_TOP_SPECIAL 'J'
  452. #define EAST_BOTTOM_SPECIAL 'L'
  453. #define EAST_CENTRE_SPECIAL 'K'
  454. for( x=1; x < max_x_loc-1; ++x)
  455. {
  456. lastExit = 0;
  457. for( y = max_y_loc-5; y >= 0; --y, lastExit=lastExit>0?lastExit-1:0)
  458. {
  459. locPtr=get_loc(x,y);
  460. HillBlockInfo *h1, *h2, *h3;
  461. char h1p, h2p, h3p;
  462. // three hill blocks on a row are pattern 9, 13, 17, 21
  463. // block above the second block is a walkable
  464. if( !lastExit && locPtr->has_hill()
  465. && (h1=hill_res[locPtr->hill_id1()])->priority == HIGH_HILL_PRIORITY
  466. && !h1->special_flag
  467. && (h1p = h1->pattern_id)
  468. && IS_EAST_EXIT_PATTERN(h1p)
  469. && get_loc(x,y+1)->has_hill()
  470. && get_loc(x,y+2)->has_hill()
  471. && (h2=hill_res[get_loc(x,y+2)->hill_id1()])->priority == HIGH_HILL_PRIORITY
  472. && (h2p = h2->pattern_id)
  473. && IS_EAST_EXIT_PATTERN(h2p)
  474. && get_loc(x,y+3)->has_hill()
  475. && (h3=hill_res[get_loc(x,y+3)->hill_id1()])->priority == HIGH_HILL_PRIORITY
  476. && (h3p = h3->pattern_id)
  477. && (h3p == EAST_PATTERN1 || h3p == EAST_PATTERN4)
  478. && get_loc(x-1, y+2)->walkable() )
  479. {
  480. short hillId, terrainId, hill2;
  481. Location *loc2;
  482. // change this square
  483. if( h1p == EAST_PATTERN3)
  484. h1p = EAST_PATTERN1;
  485. else if( h1p == EAST_PATTERN4)
  486. h1p = EAST_PATTERN2;
  487. hillId = hill_res.scan(h1p, HIGH_HILL_PRIORITY, EAST_TOP_SPECIAL, 0);
  488. hill2 = locPtr->hill_id2();
  489. locPtr->remove_hill();
  490. locPtr->set_hill(hillId);
  491. if( hill2 )
  492. locPtr->set_hill(hill2);
  493. err_when( locPtr->has_hill() && locPtr->walkable());
  494. //### begin alex 24/6 ###//
  495. locPtr->set_power_off();
  496. set_surr_power_off(x, y);
  497. //#### end alex 24/6 ####//
  498. // next row
  499. loc2 = get_loc(x, y+1);
  500. hillId = hill_res.locate(h1p, hill_res[hillId]->sub_pattern_id,
  501. LOW_HILL_PRIORITY, EAST_TOP_SPECIAL);
  502. loc2->remove_hill();
  503. loc2->set_hill(hillId);
  504. //### begin alex 24/6 ###//
  505. loc2->set_power_off();
  506. set_surr_power_off(x, y+1);
  507. //#### end alex 24/6 ####//
  508. if((terrainId = terrain_res.scan(terrainType-1, terrainType-1,
  509. 0, 0, 1, 0)) != 0 )
  510. loc2->terrain_id = terrainId;
  511. err_when( loc2->has_hill() && loc2->walkable());
  512. // third row
  513. loc2 = get_loc(x, y+2);
  514. loc2->remove_hill();
  515. loc2->walkable_reset();
  516. //if((terrainId = terrain_res.scan(terrainType-1, terrainType-1,
  517. // 0, 0, 1, EAST_CENTRE_SPECIAL)) != 0 )
  518. // loc2->terrain_id = terrainId;
  519. if((terrainId = terrain_res.scan(terrainType, terrainType-1,
  520. EAST_PATTERN2, 0, 1, EAST_CENTRE_SPECIAL )) != 0 )
  521. loc2->terrain_id = terrainId;
  522. err_when( loc2->has_hill() && loc2->walkable());
  523. // next column
  524. //loc2 = get_loc(x-1, y+2);
  525. //if((terrainId = terrain_res.scan(terrainType, terrainType-1,
  526. // EAST_PATTERN2, 0, 1, EAST_CENTRE_SPECIAL )) != 0 )
  527. // loc2->terrain_id = terrainId;
  528. //err_when( loc2->has_hill() && loc2->walkable());
  529. // fourth row
  530. loc2 = get_loc(x, y+3);
  531. if( h3p == EAST_PATTERN4)
  532. h3p = EAST_PATTERN1;
  533. if( h3p == EAST_PATTERN3)
  534. h3p = EAST_PATTERN2;
  535. hillId = hill_res.scan(h3p, HIGH_HILL_PRIORITY, EAST_BOTTOM_SPECIAL, 0);
  536. loc2->remove_hill();
  537. loc2->set_hill(hillId);
  538. //### begin alex 24/6 ###//
  539. loc2->set_power_off();
  540. set_surr_power_off(x, y+3);
  541. //#### end alex 24/6 ####//
  542. if((terrainId = terrain_res.scan(terrainType-1, terrainType-1,
  543. 0, 0, 1, 0)) != 0 )
  544. loc2->terrain_id = terrainId;
  545. err_when( loc2->has_hill() && loc2->walkable());
  546. // next row
  547. loc2 = get_loc(x, y+4);
  548. hillId = hill_res.locate(h3p, hill_res[hillId]->sub_pattern_id,
  549. LOW_HILL_PRIORITY, EAST_BOTTOM_SPECIAL);
  550. loc2->set_hill(hillId);
  551. //### begin alex 24/6 ###//
  552. loc2->set_power_off();
  553. set_surr_power_off(x, y+4);
  554. //#### end alex 24/6 ####//
  555. if((terrainId = terrain_res.scan(terrainType-1, terrainType-1,
  556. 0, 0, 1, 0)) != 0 )
  557. loc2->terrain_id = terrainId;
  558. err_when( loc2->has_hill() && loc2->walkable());
  559. lastExit = MIN_EXIT_SEPARATION;
  560. }
  561. }
  562. }
  563. }
  564. // ---------- end of function World::gen_hills -------//
  565. // ---------- begin of function World::put_hill_set ------//
  566. void World::put_hill_set(short *px, short *py, short hSetId)
  567. {
  568. }
  569. // ---------- end of function World::put_hill_pattern ------//
  570. // ---------- begin of function World::put_hill_pattern ------//
  571. void World::put_hill_pattern(short *px, short *py, unsigned char patternId)
  572. {
  573. }
  574. // ---------- end of function World::put_hill_pattern ------//
  575. // ---------- begin of function World::fill_hill -------//
  576. void World::fill_hill(short x, short y)
  577. {
  578. }
  579. // ---------- end of function World::fill_hill -------//