ONEWSENG.cpp 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475
  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 : ONEWS3.CPP
  21. //Description : Object news msg generating routines
  22. #if( !defined(GERMAN) && !defined(FRENCH) && !defined(SPANISH) )
  23. #include <OSTR.h>
  24. #include <OTOWN.h>
  25. #include <OFIRMRES.h>
  26. #include <ONATION.h>
  27. #include <OUNIT.h>
  28. #include <OSPY.h>
  29. #include <OFONT.h>
  30. #include <OTECHRES.h>
  31. #include <OMONSRES.h>
  32. #include <OREMOTE.h>
  33. #include <OGODRES.h>
  34. #include <ORACERES.h>
  35. #include <OTALKRES.h>
  36. #include <ONEWS.h>
  37. //--------- Define variable type ----------//
  38. typedef void (News::*NewsFP)();
  39. //-------- Define struct NewsInfo -------//
  40. struct NewsInfo
  41. {
  42. NewsFP news_function_ptr;
  43. char is_major; // whether this is a major news or not
  44. };
  45. //------ Define function pointers array ------//
  46. static NewsInfo news_info_array[] =
  47. {
  48. { &News::diplomacy, 1 },
  49. { &News::town_rebel, 1 },
  50. { &News::migrate, 0 },
  51. { &News::new_nation, 1 },
  52. { &News::nation_destroyed, 1 },
  53. { &News::nation_surrender, 1 },
  54. { &News::king_die, 1 },
  55. { &News::new_king, 1 },
  56. { &News::firm_destroyed, 0 },
  57. { &News::firm_captured, 0 },
  58. { &News::town_destroyed, 0 },
  59. { &News::town_abandoned, 0 },
  60. { &News::town_surrendered, 0 },
  61. { &News::monster_king_killed, 0 },
  62. { &News::monster_firm_destroyed, 0 },
  63. { &News::scroll_acquired, 1 },
  64. { &News::monster_gold_acquired, 0 },
  65. { &News::your_spy_killed, 1 },
  66. { &News::enemy_spy_killed, 1 },
  67. { &News::unit_betray, 1 },
  68. { &News::unit_assassinated, 1 },
  69. { &News::assassinator_caught, 1 },
  70. { &News::general_die, 1 },
  71. { &News::raw_exhaust, 1 },
  72. { &News::tech_researched, 1 },
  73. { &News::lightning_damage, 1 },
  74. { &News::earthquake_damage, 1 },
  75. { &News::goal_deadline, 1 },
  76. { &News::weapon_ship_worn_out, 0 },
  77. { &News::firm_worn_out, 0 },
  78. { &News::chat_msg, 1 },
  79. { &News::multi_retire, 1 },
  80. { &News::multi_quit_game, 1 },
  81. { &News::multi_save_game, 1 },
  82. { &News::multi_connection_lost, 1 },
  83. };
  84. //------- Define static variables --------//
  85. static String str;
  86. //------ Begin of function News::msg -----//
  87. //
  88. // Return the msg string of current news.
  89. //
  90. char* News::msg()
  91. {
  92. NewsFP newsFP = news_info_array[id-1].news_function_ptr;
  93. (this->*newsFP)(); // call the corrsponding function to return the news msg
  94. return str;
  95. }
  96. //------- End of function News::msg -----//
  97. //------ Begin of function News::is_major -----//
  98. //
  99. // Whether this is a major news or not.
  100. //
  101. int News::is_major()
  102. {
  103. if( id==NEWS_TOWN_REBEL )
  104. {
  105. //-- only rebellions happening in the player's village are considered as major news --//
  106. return nation_array.player_recno &&
  107. nation_name_id1 == (~nation_array)->nation_name_id;
  108. }
  109. else
  110. {
  111. return news_info_array[id-1].is_major;
  112. }
  113. }
  114. //------- End of function News::is_major -----//
  115. //------ Begin of function News::diplomacy -----//
  116. //
  117. // Diplomatic messages from other nations.
  118. //
  119. // short_para1 = the recno of TalkMsg in talk_res.talk_msg_array.
  120. //
  121. void News::diplomacy()
  122. {
  123. err_when( talk_res.is_talk_msg_deleted(short_para1) );
  124. TalkMsg* talkMsgPtr = talk_res.get_talk_msg(short_para1);
  125. str = talkMsgPtr->msg_str(nation_array.player_recno);
  126. }
  127. //------- End of function News::diplomacy -----//
  128. //------ Begin of function News::town_rebel -----//
  129. //
  130. // Generate a news that a firm is built
  131. //
  132. // nation_name1() - the name of the nation the rebel took place.
  133. //
  134. // short_para1 = the town name id.
  135. // short_para2 = no. of rebels
  136. //
  137. void News::town_rebel()
  138. {
  139. //---------------- Text Format -----------------//
  140. //
  141. // <no. of rebel> Peasants in <town name> in
  142. // <nation name> is/are rebelling.
  143. //
  144. //----------------------------------------------//
  145. err_when( short_para2 < 1 );
  146. str = short_para2;
  147. if( short_para2 == 1 )
  148. str += " Peasant in ";
  149. else
  150. str += " Peasants in ";
  151. str += town_res.get_name(short_para1);
  152. str += " in ";
  153. str += nation_name1();
  154. if( short_para2 > 1 )
  155. str += " are rebelling.";
  156. else
  157. str += " is rebelling.";
  158. }
  159. //------- End of function News::town_rebel -----//
  160. //------ Begin of function News::migrate -------//
  161. //
  162. // nation_name1() - from nation
  163. // nation_name2() - to nation
  164. //
  165. // short_para1 = the town name id. that the worker migrates from
  166. // short_para2 = the town name id. that the worker migrates to
  167. // short_para3 = race id. of the migrated worker/peasant
  168. // short_para4 = no. of people migrated
  169. // short_para5 = the firm id. that the worker works for
  170. //
  171. void News::migrate()
  172. {
  173. //---------------- Text Format -----------------//
  174. //
  175. // A <racial> <worker name>/Peasant has emigrated from your
  176. // village of <town name> to <town name> in <nation name>.
  177. //
  178. // A <racial> <worker name>/Peasant has immigrated from
  179. // <town name> in <nation name> to your village of <town name>.
  180. //
  181. //----------------------------------------------//
  182. if( short_para4 == 1 )
  183. str = "A";
  184. else
  185. str = m.format(short_para4);
  186. str += " ";
  187. str += race_res[short_para3]->name;
  188. str += " ";
  189. if( short_para5 )
  190. str += firm_res[short_para5]->worker_title;
  191. else
  192. str += "Peasant";
  193. if( short_para4 == 1 )
  194. str += " has";
  195. else
  196. str += "s have";
  197. //------------------------------------//
  198. if( nation_array.player_recno && nation_name_id1 == (~nation_array)->nation_name_id ) // from player nation to another nation
  199. {
  200. str += " emigrated from your village of ";
  201. str += town_res.get_name(short_para1);
  202. str += " to ";
  203. str += town_res.get_name(short_para2);
  204. if( nation_name_id2 ) // only if it is not an independent town
  205. {
  206. str += " in ";
  207. str += nation_name2();
  208. }
  209. str += ".";
  210. }
  211. else
  212. {
  213. str += " immigrated from ";
  214. str += town_res.get_name(short_para1);
  215. if( nation_name_id1 )
  216. {
  217. str += " in ";
  218. str += nation_name1();
  219. }
  220. str += " to your village of ";
  221. str += town_res.get_name(short_para2);
  222. str += ".";
  223. }
  224. }
  225. //------- End of function News::migrate --------//
  226. //------ Begin of function News::new_nation -----//
  227. //
  228. // king_name1() - name of the king of the new kingdom.
  229. //
  230. void News::new_nation()
  231. {
  232. //---------------- Text Format -----------------//
  233. //
  234. // A new Kingdom has emerged under the leadership of <king Name>.
  235. //
  236. //----------------------------------------------//
  237. str = "A new Kingdom has emerged under the leadership of ";
  238. str += king_name1(1);
  239. str += ".";
  240. }
  241. //------- End of function News::new_nation -----//
  242. //------ Begin of function News::nation_destroyed -----//
  243. //
  244. // nation_name1() - name of the destroyed nation.
  245. //
  246. void News::nation_destroyed()
  247. {
  248. //---------------- Text Format -----------------//
  249. //
  250. // <King>'s Kingdom has been destroyed.
  251. //
  252. //----------------------------------------------//
  253. str = nation_name1();
  254. str += " has been destroyed.";
  255. }
  256. //------- End of function News::nation_destroyed -----//
  257. //------ Begin of function News::nation_surrender -----//
  258. //
  259. // nation_name1() - name of the surrendering nation.
  260. // nation_name2() - name of the nation to surrender.
  261. //
  262. void News::nation_surrender()
  263. {
  264. //---------------- Text Format -----------------//
  265. //
  266. // <King>'s Kingdom has surrendered to <King B>'s Kingdom.
  267. //
  268. // <King>'s Kingdom has surrendered to you.
  269. //
  270. //----------------------------------------------//
  271. str = nation_name1();
  272. str += " has surrendered to ";
  273. if( nation_array.player_recno && nation_name_id2 == (~nation_array)->nation_name_id )
  274. {
  275. str += "you.";
  276. }
  277. else
  278. {
  279. str += nation_name2();
  280. str += ".";
  281. }
  282. }
  283. //------- End of function News::nation_surrender -----//
  284. //------ Begin of function News::king_die -----//
  285. //
  286. // king_name1() - the nation whose king has died.
  287. //
  288. void News::king_die()
  289. {
  290. //---------------- Text Format -----------------//
  291. //
  292. // Your King, <king name>, has been slain.
  293. //
  294. // OR
  295. //
  296. // King <king name> of <nation name> has been slain.
  297. //
  298. //----------------------------------------------//
  299. if( nation_array.player_recno && nation_name_id1 == (~nation_array)->nation_name_id )
  300. {
  301. str = "Your King, ";
  302. str += king_name1();
  303. str += ", has been slain.";
  304. }
  305. else
  306. {
  307. str = "King ";
  308. str += king_name1();
  309. str += " of ";
  310. str += nation_name1();
  311. str += " has been slain.";
  312. }
  313. }
  314. //------- End of function News::king_die -----//
  315. //------ Begin of function News::new_king -----//
  316. //
  317. // nation_name1() - name of the nation where there is a new king.
  318. //
  319. // short_para1 - race id. of the new king.
  320. // short_para2 - name id. of the new king.
  321. //
  322. void News::new_king()
  323. {
  324. //---------------- Text Format -----------------//
  325. //
  326. // <unit name> has ascended the throne as your new King.
  327. //
  328. // OR
  329. //
  330. // <unit name> has ascended the throne as the new King of
  331. // <nation name>.
  332. //
  333. //----------------------------------------------//
  334. str = race_res[short_para1]->get_name(short_para2);
  335. if( nation_array.player_recno && nation_name_id1 == (~nation_array)->nation_name_id )
  336. {
  337. str += " has ascended the throne as your new King.";
  338. }
  339. else
  340. {
  341. str += " has ascended the throne as the new King of ";
  342. str += nation_name1();
  343. str += ".";
  344. }
  345. }
  346. //------- End of function News::new_king -----//
  347. //------ Begin of function News::firm_destroyed -----//
  348. //
  349. // short_para1 - name id. of the firm destroyed.
  350. // short_para2 - id of the town where the firm is located.
  351. // short_para3 - destroyer type: 1 - a nation, 2 - rebels, 3 - Fryhtans.
  352. //
  353. void News::firm_destroyed()
  354. {
  355. //---------------- Text Format -----------------//
  356. //
  357. // Your <firm type> near <town name> has been destroyed by <kingdom name>.
  358. // Your <firm type> near <town name> has been destroyed by Rebels.
  359. // Your <firm type> near <town name> has been destroyed by Fryhtans.
  360. //
  361. //----------------------------------------------//
  362. str = "Your ";
  363. str += firm_res[short_para1]->name;
  364. str += " near ";
  365. str += town_res.get_name(short_para2);
  366. str += " has been destroyed";
  367. // ##### patch begin Gilbert 10/2 ######//
  368. switch( short_para3 )
  369. // ##### patch end Gilbert 10/2 ######//
  370. {
  371. case DESTROYER_NATION:
  372. str += " by ";
  373. str += nation_name2();
  374. str += ".";
  375. break;
  376. case DESTROYER_REBEL:
  377. str += " by Rebels.";
  378. break;
  379. case DESTROYER_MONSTER:
  380. str += " by Fryhtans.";
  381. break;
  382. case DESTROYER_UNKNOWN:
  383. str += ".";
  384. break;
  385. }
  386. }
  387. //------- End of function News::firm_destroyed -----//
  388. //------ Begin of function News::firm_captured -----//
  389. //
  390. // nation_name2() - name of the nation that took over your firm.
  391. //
  392. // short_para1 - id. of the firm took over
  393. // short_para2 - id of the town where the firm is located.
  394. // short_para3 - whether the capturer of the firm is a spy.
  395. //
  396. void News::firm_captured()
  397. {
  398. //---------------- Text Format -----------------//
  399. //
  400. // Your <firm type> near <town name> has been
  401. // captured by <kingdom name>.
  402. //
  403. // If the capturer is a spy:
  404. //
  405. // Your <firm type> near <town name> has been
  406. // captured by a spy from <kingdom name>.
  407. //
  408. //----------------------------------------------//
  409. str = "Your ";
  410. str += firm_res[short_para1]->name;
  411. str += " near ";
  412. str += town_res.get_name(short_para2);
  413. str += " has been captured by ";
  414. if( short_para3 )
  415. str += "a spy from ";
  416. str += nation_name2();
  417. str += ".";
  418. }
  419. //------- End of function News::firm_captured -----//
  420. //------ Begin of function News::town_destroyed -----//
  421. //
  422. // short_para1 - name id. of the town
  423. // short_para2 - destroyer type
  424. //
  425. void News::town_destroyed()
  426. {
  427. //---------------- Text Format -----------------//
  428. //
  429. // Your village of <name name> has been destroyed by <kingdom name>.
  430. // Your village of <name name> has been destroyed by Rebels.
  431. // Your village of <name name> has been destroyed by Fryhtans.
  432. //
  433. //----------------------------------------------//
  434. str = "Your village of ";
  435. str += town_res.get_name(short_para1);
  436. str += " has been destroyed";
  437. switch( short_para2 )
  438. {
  439. case DESTROYER_NATION:
  440. str += " by ";
  441. str += nation_name2();
  442. str += ".";
  443. break;
  444. case DESTROYER_REBEL:
  445. str += " by Rebels.";
  446. break;
  447. case DESTROYER_MONSTER:
  448. str += " by Fryhtans.";
  449. break;
  450. case DESTROYER_UNKNOWN:
  451. str += ".";
  452. break;
  453. }
  454. }
  455. //------- End of function News::town_destroyed -----//
  456. //------ Begin of function News::town_abandoned -----//
  457. //
  458. // short_para1 - name id of the town
  459. //
  460. void News::town_abandoned()
  461. {
  462. //---------------- Text Format -----------------//
  463. //
  464. // Your village of <village name> has been abandoned by
  465. // its people.
  466. //
  467. //----------------------------------------------//
  468. str = "Your village of ";
  469. str += town_res.get_name(short_para1);
  470. str += " has been abandoned by its people.";
  471. }
  472. //------- End of function News::town_abandoned -----//
  473. //------ Begin of function News::town_surrendered -----//
  474. //
  475. // short_para1 - name id. of the surrendering town.
  476. //
  477. // nation_name1() - name of the nation the town surrenders to.
  478. // nation_name2() - name of the nation of the surrendering town.
  479. //
  480. void News::town_surrendered()
  481. {
  482. //---------------- Text Format -----------------//
  483. //
  484. // The village of <village name> in <King's Kingdom> has
  485. // surrendered to you.
  486. //
  487. // The independent village of <village name> has
  488. // surrendered to you.
  489. //
  490. // Your village of <village name> has surrendered
  491. // to <King's Kingdom>.
  492. //
  493. //----------------------------------------------//
  494. if( nation_array.player_recno && nation_name_id2 == (~nation_array)->nation_name_id )
  495. {
  496. str = "Your village of ";
  497. str += town_res.get_name(short_para1);
  498. str += " has surrendered to ";
  499. str += nation_name1();
  500. str += ".";
  501. }
  502. else if( nation_name_id2 )
  503. {
  504. str = "The village of ";
  505. str += town_res.get_name(short_para1);
  506. str += " in ";
  507. str += nation_name2();
  508. str += " has surrendered to you.";
  509. }
  510. else // nation_name_id2 == 0, it's an independent town
  511. {
  512. str = "The independent village of ";
  513. str += town_res.get_name(short_para1);
  514. str += " has surrendered to you.";
  515. }
  516. }
  517. //------- End of function News::town_surrendered -----//
  518. //------ Begin of function News::monster_king_killed -----//
  519. //
  520. // short_para1 - monster id.
  521. //
  522. void News::monster_king_killed()
  523. {
  524. //---------------- Text Format -----------------//
  525. //
  526. // An All High <monster type name> has been slain.
  527. //
  528. //----------------------------------------------//
  529. str = "An All High ";
  530. str += monster_res[short_para1]->name;
  531. str += " has been slain.";
  532. }
  533. //------- End of function News::monster_king_killed -----//
  534. //------ Begin of function News::monster_firm_destroyed -----//
  535. //
  536. // short_para1 - monster id.
  537. //
  538. void News::monster_firm_destroyed()
  539. {
  540. //---------------- Text Format -----------------//
  541. //
  542. // A <monster type name> Lair has been destroyed.
  543. //
  544. //----------------------------------------------//
  545. char* nameStr = monster_res[short_para1]->name;
  546. if( nameStr[0] == 'I' ) // "An Ick Lair"
  547. str = "An ";
  548. else
  549. str = "A ";
  550. str += nameStr;
  551. str += " Lair has been destroyed.";
  552. }
  553. //------- End of function News::monster_firm_destroyed -----//
  554. //------ Begin of function News::scroll_acquired -----//
  555. //
  556. // nation_name1() - the nation that has acquired the scroll.
  557. //
  558. // short_para1 = the race id. of the scroll.
  559. //
  560. void News::scroll_acquired()
  561. {
  562. //---------------- Text Format -----------------//
  563. //
  564. // You have acquired the <race name> Scroll of Power.
  565. // <nation name> has acquired the <race name> Scroll of Power.
  566. //
  567. //----------------------------------------------//
  568. if( nation_array.player_recno && nation_name_id1 == (~nation_array)->nation_name_id )
  569. {
  570. str = "You have acquired the ";
  571. }
  572. else
  573. {
  574. str = nation_name1();
  575. str += " has acquired ";
  576. }
  577. str += race_res[short_para1]->adjective;
  578. str += " Scroll of Power.";
  579. }
  580. //------- End of function News::scroll_acquired -----//
  581. //------ Begin of function News::monster_gold_acquired -----//
  582. //
  583. // nation_name1() - the nation that has acquired the monster treasure.
  584. //
  585. // short_para1 = amount of gold.
  586. //
  587. void News::monster_gold_acquired()
  588. {
  589. //---------------- Text Format -----------------//
  590. //
  591. // Your have recovered <treasure amount> worth of treasure from the Fryhtans.
  592. //
  593. //----------------------------------------------//
  594. str = "You have recovered ";
  595. str += m.format(short_para1,2);
  596. str += " worth of treasure from the Fryhtans.";
  597. }
  598. //------- End of function News::monster_gold_acquired -----//
  599. //------ Begin of function News::your_spy_killed -----//
  600. //
  601. // nation_name1() - your nation.
  602. // nation_name2() - the nation that killed your spy.
  603. //
  604. // short_para1 - firm id. if it's a firm
  605. // 0 if it's a town
  606. // race id if spy place == SPY_MOBILE
  607. // short_para2 - the town id.
  608. // name id if spy place == SPY_MOBILE
  609. // short_para3 - spy place
  610. //
  611. void News::your_spy_killed()
  612. {
  613. //---------------- Text Format -----------------//
  614. //
  615. // Your spy has been exposed and executed on his mission to
  616. // <village name> [ in <nation name> ]. (no nation name for independent town.)
  617. //
  618. // Your spy has been exposed and executed on his mission to
  619. // a <firm type name> near <village name> in <nation name>.
  620. //
  621. // Your spy <spy name> has been exposed and executed on his mission to
  622. // <nation name>.
  623. //
  624. //----------------------------------------------//
  625. if( short_para3 == SPY_FIRM )
  626. {
  627. str = "Your spy has been exposed and executed on his mission to a ";
  628. str += firm_res[short_para1]->name;
  629. str += " near ";
  630. str += town_res.get_name(short_para2);
  631. if( nation_name_id2 ) // not for independent town.
  632. {
  633. str += " in ";
  634. str += nation_name2();
  635. }
  636. }
  637. else if( short_para3 == SPY_TOWN )
  638. {
  639. str = "Your spy has been exposed and executed on his mission to ";
  640. str += town_res.get_name(short_para2);
  641. if( nation_name_id2 ) // not for independent town.
  642. {
  643. str += " in ";
  644. str += nation_name2();
  645. }
  646. }
  647. else if( short_para3 == SPY_MOBILE )
  648. {
  649. str = "Your spy ";
  650. str += race_res[short_para1]->get_name(short_para2);
  651. str += " has been exposed and executed on his mission";
  652. if( nation_name_id2 ) // not for independent town.
  653. {
  654. str += " to ";
  655. str += nation_name2();
  656. }
  657. }
  658. str += ".";
  659. }
  660. //------- End of function News::your_spy_killed -----//
  661. //------ Begin of function News::enemy_spy_killed -----//
  662. //
  663. // nation_name1() - your nation.
  664. // nation_name2() - the nation that the spy belongs to.
  665. //
  666. // short_para1 - firm id. if it's a firm
  667. // 0 if it's a town
  668. // short_para2 - town name id. if it's a town
  669. // 0 if it's a firm
  670. // short_para3 - id of the town where the firm is located.
  671. //
  672. void News::enemy_spy_killed()
  673. {
  674. //---------------- Text Format -----------------//
  675. //
  676. // A spy from <kingdom> has been uncovered and executed in your
  677. // <firm type> near <town name>.
  678. //
  679. // A spy from <kingdom> has been uncovered and executed in your
  680. // village of <town name>.
  681. //
  682. // Spy <spy name> from <kingdom> has been uncovered and executed.
  683. //
  684. //----------------------------------------------//
  685. if( short_para3==SPY_FIRM || short_para3==SPY_TOWN )
  686. {
  687. str = "A spy from ";
  688. str += nation_name2();
  689. str += " has been uncovered and executed in your ";
  690. if( short_para3==SPY_FIRM )
  691. {
  692. str += firm_res[short_para1]->name;
  693. str += " near ";
  694. str += town_res.get_name(short_para2);
  695. str += ".";
  696. }
  697. else
  698. {
  699. str += "village of ";
  700. str += town_res.get_name(short_para2);
  701. str += ".";
  702. }
  703. }
  704. else
  705. {
  706. err_when( short_para3 != SPY_MOBILE );
  707. str = "Spy ";
  708. str += race_res[short_para1]->get_name(short_para2);
  709. str += " from ";
  710. str += nation_name2();
  711. str += " has been uncovered and executed.";
  712. }
  713. }
  714. //------- End of function News::enemy_spy_killed -----//
  715. //------ Begin of function News::unit_betray -----//
  716. //
  717. // Only for mobile units or generals in command base.
  718. //
  719. // nation_name1() - the nation that the unit originally belongs to.
  720. // nation_name2() - the nation that the unit has turned towards.
  721. //
  722. // short_para1 - race id. of the unit
  723. // short_para2 - name id. of the unit
  724. // short_para3 - rank id. of the unit
  725. //
  726. void News::unit_betray()
  727. {
  728. //---------------- Text Format -----------------//
  729. //
  730. // [General] <unit name> has betrayed you and turned towards
  731. // <nation name>.
  732. //
  733. // [General] <unit name> has renounced you and become independent.
  734. //
  735. // [General] <unit name> of <nation name> has defected to your
  736. // forces.
  737. //
  738. // Independent unit <unit name> has joined your forces.
  739. //
  740. //----------------------------------------------//
  741. if( nation_name_id1 == 0 ) // independent unit joining your force
  742. {
  743. str = "Independent unit ";
  744. str += race_res[short_para1]->get_name(short_para2);
  745. str += " has joined your force.";
  746. return;
  747. }
  748. //------------------------------------//
  749. if( short_para3==RANK_GENERAL )
  750. str = "General ";
  751. else
  752. str = "";
  753. str += race_res[short_para1]->get_name(short_para2);
  754. //---------------------------------//
  755. if( nation_name_id2 == 0 ) // became an independent unit
  756. {
  757. str += " has renounced you and become independent.";
  758. }
  759. else
  760. {
  761. if( nation_array.player_recno && nation_name_id1 == (~nation_array)->nation_name_id )
  762. {
  763. str += " has betrayed you and turned towards ";
  764. str += nation_name2();
  765. str += ".";
  766. }
  767. else
  768. {
  769. str += " of ";
  770. str += nation_name1();
  771. str += " has defected to your forces.";
  772. }
  773. }
  774. }
  775. //------- End of function News::unit_betray -----//
  776. //------ Begin of function News::general_die -----//
  777. //
  778. // short_para1 - race id. of your general
  779. // short_para2 - name id. of your general
  780. //
  781. void News::general_die()
  782. {
  783. //---------------- Text Format -----------------//
  784. //
  785. // Your general, <general name>, has been slain.
  786. //
  787. //----------------------------------------------//
  788. str = "Your general, ";
  789. str += race_res[short_para1]->get_single_name( (WORD)short_para2 );
  790. str += ", has been slain.";
  791. }
  792. //------- End of function News::general_die -----//
  793. //------ Begin of function News::unit_assassinated -----//
  794. //
  795. // short_para1 - race id. of assassinated unit
  796. // short_para2 - name id. of assassinated unit
  797. // short_para3 - rank id. of assassinated unit
  798. // short_para4 - whether the enemy spy has been killed or not.
  799. //
  800. void News::unit_assassinated()
  801. {
  802. //---------------- Text Format -----------------//
  803. //
  804. // Your King, <king name>, has been assassinated by an enemy spy.
  805. // Your general, <general name>, has been assassinated by an enemy spy.
  806. //
  807. // [The enemy spy has been killed.]
  808. //
  809. //----------------------------------------------//
  810. if( short_para3 == RANK_KING )
  811. {
  812. str = "Your King, ";
  813. str += race_res[short_para1]->get_single_name( (WORD)short_para2 );
  814. }
  815. else
  816. {
  817. str = "Your general, ";
  818. str += race_res[short_para1]->get_single_name( (WORD)short_para2 );
  819. }
  820. str += ", has been assassinated by an enemy spy.";
  821. if( short_para4 )
  822. str += " The enemy spy has been killed.";
  823. }
  824. //------- End of function News::unit_assassinated -----//
  825. //------ Begin of function News::assassinator_caught -----//
  826. //
  827. // short_para1 - rank id. of the assassinating target.
  828. //
  829. void News::assassinator_caught()
  830. {
  831. //---------------- Text Format -----------------//
  832. //
  833. // An enemy spy has been killed while attempting
  834. // to assassinate your King/General.
  835. //
  836. //----------------------------------------------//
  837. str = "An enemy spy has been killed while attempting to assassinate your ";
  838. if( short_para1 == RANK_KING )
  839. str += "King.";
  840. else
  841. str += "General.";
  842. }
  843. //------- End of function News::assassinator_caught -----//
  844. //------ Begin of function News::raw_exhaust -----//
  845. //
  846. // short_para1 - raw id.
  847. //
  848. void News::raw_exhaust()
  849. {
  850. //---------------- Text Format -----------------//
  851. //
  852. // Your <raw type> Mine has exhausted its <raw type> deposit.
  853. //
  854. //----------------------------------------------//
  855. str = "Your ";
  856. str += raw_res[short_para1]->name;
  857. str += " Mine has exhausted its ";
  858. str += raw_res[short_para1]->name;
  859. str += " deposit.";
  860. }
  861. //------- End of function News::raw_exhaust -----//
  862. //------ Begin of function News::tech_researched -----//
  863. //
  864. // short_para1 - tech id.
  865. // short_para2 - tech version.
  866. //
  867. void News::tech_researched()
  868. {
  869. //---------------- Text Format -----------------//
  870. //
  871. // Your scientists have finished their <technology>
  872. // [Mark <version>] research.
  873. //
  874. //----------------------------------------------//
  875. str = "Your scientists have finished their ";
  876. str += tech_res[short_para1]->tech_des();
  877. if( tech_res[short_para1]->max_tech_level > 1 ) // if the tech has more than one level
  878. {
  879. str += " Mark ";
  880. str += m.roman_number(short_para2);
  881. }
  882. str += " research.";
  883. }
  884. //------- End of function News::tech_researched -----//
  885. //------ Begin of function News::lightning_damage -----//
  886. //
  887. void News::lightning_damage()
  888. {
  889. //---------------- Text Format -----------------//
  890. //
  891. // Your <unit name> has been struck and injured/killed by lightning.
  892. //
  893. // Your <firm name> near <village name> has been struck/destroyed by lightning.
  894. //
  895. // Your village <village name> has been struck/destroyed by lightning.
  896. //
  897. //----------------------------------------------//
  898. str = "Your ";
  899. switch( short_para1 )
  900. {
  901. case NEWS_LOC_UNIT:
  902. if( short_para4 == RANK_GENERAL )
  903. str += "General ";
  904. else if( short_para4 == RANK_KING )
  905. str += "King ";
  906. else
  907. str += "unit ";
  908. if( short_para2 > 0 )
  909. str += race_res[short_para2]->get_name((WORD) short_para3);
  910. else
  911. str += unit_res[short_para3]->name;
  912. break;
  913. case NEWS_LOC_FIRM:
  914. str += firm_res[short_para2]->name;
  915. if( short_para3 )
  916. {
  917. str += " near ";
  918. str += town_res.get_name(short_para3);
  919. }
  920. break;
  921. case NEWS_LOC_TOWN:
  922. str += "village ";
  923. str += town_res.get_name(short_para3);
  924. break;
  925. default:
  926. err_here();
  927. }
  928. //----------------------------------//
  929. str += " has been ";
  930. if( short_para1==NEWS_LOC_UNIT )
  931. {
  932. if( short_para5 )
  933. str += "struck and killed ";
  934. else
  935. str += "struck and injured ";
  936. }
  937. else
  938. {
  939. if( short_para5 )
  940. str += "destroyed ";
  941. else
  942. str += "struck ";
  943. }
  944. str += "by lightning.";
  945. }
  946. //------- End of function News::lightning_damage -----//
  947. //------ Begin of function News::earthquake_damage -----//
  948. //
  949. void News::earthquake_damage()
  950. {
  951. //---------------- Text Format -----------------//
  952. //
  953. // <number> of your units has/have been injured and <number> killed
  954. // in an earthquake.
  955. //
  956. // <number> of your villagers has/have been killed in an earthquake.
  957. //
  958. // <number> of your buildings has/have been damaged and <number> destroyed
  959. // in an earthquake.
  960. //
  961. //----------------------------------------------//
  962. int conjunction = 0;
  963. str = "";
  964. // ###### begin Gilbert 12/9 ##########//
  965. if( short_para1 == 1)
  966. {
  967. str += short_para2;
  968. str += " of your unit";
  969. if( short_para2 == 1)
  970. str += " has";
  971. else
  972. str += "s have";
  973. str += " been injured";
  974. if( short_para3 > 0)
  975. {
  976. str += " and ";
  977. str += short_para3;
  978. str += " killed";
  979. }
  980. str += " in an earthquake";
  981. }
  982. else if( short_para1 == 2 )
  983. {
  984. if( short_para2 > 0)
  985. {
  986. str += short_para2;
  987. str += " of your villager";
  988. if( short_para2 == 1)
  989. str += " has";
  990. else
  991. str += "s have";
  992. str += " been killed in an earthquake";
  993. }
  994. }
  995. else if( short_para1 == 3)
  996. {
  997. str += short_para2;
  998. str += " of your building";
  999. if( short_para2 == 1)
  1000. str += " has";
  1001. else
  1002. str += "s have";
  1003. str += " been damaged";
  1004. if( short_para3 > 0)
  1005. {
  1006. str += " and ";
  1007. str += short_para3;
  1008. str += " destroyed";
  1009. }
  1010. str += " in an earthquake.";
  1011. }
  1012. else
  1013. err_here();
  1014. // ###### end Gilbert 12/9 ##########//
  1015. }
  1016. //------- End of function News::earthquake_damage -----//
  1017. //------ Begin of function News::goal_deadline -----//
  1018. //
  1019. // Display a warning message as the deadline of the goals approaches.
  1020. //
  1021. // short_para1 - years left before the deadline.
  1022. // short_para2 - months left before the deadline.
  1023. //
  1024. void News::goal_deadline()
  1025. {
  1026. //---------------- Text Format -----------------//
  1027. //
  1028. // Make haste! You have only <year> year[s] and <month> month[s]
  1029. // left to achieve your goal.
  1030. //
  1031. //----------------------------------------------//
  1032. str = "Make haste! You have only ";
  1033. if( short_para1 )
  1034. {
  1035. str += short_para1;
  1036. if( short_para1 > 1 )
  1037. str += " years ";
  1038. else
  1039. str += " year ";
  1040. }
  1041. if( short_para1 && short_para2 )
  1042. str += "and ";
  1043. if( short_para2 )
  1044. {
  1045. str += short_para2;
  1046. if( short_para2 > 1 )
  1047. str += " months ";
  1048. else
  1049. str += " month ";
  1050. }
  1051. str += "left to achieve your goal.";
  1052. }
  1053. //------- End of function News::goal_deadline -----//
  1054. //------ Begin of function News::weapon_ship_worn_out -----//
  1055. //
  1056. // Your weapon or ship worn out and destroyed due to lack of money for
  1057. // maintenance.
  1058. //
  1059. // short_para1 - unit id. of the weapon
  1060. // short_para2 - level of the weapon
  1061. //
  1062. void News::weapon_ship_worn_out()
  1063. {
  1064. //---------------- Text Format -----------------//
  1065. //
  1066. // A <weapon name> <weapon level> of yours has broken
  1067. // down due to the lack of maintenance funds.
  1068. //
  1069. //----------------------------------------------//
  1070. str = "A ";
  1071. str += unit_res[short_para1]->name;
  1072. if( short_para2 )
  1073. {
  1074. str += " ";
  1075. str += m.roman_number(short_para2);
  1076. }
  1077. str += " of yours has broken down due to the lack of maintenance funds.";
  1078. }
  1079. //------- End of function News::weapon_ship_worn_out -----//
  1080. //------ Begin of function News::firm_worn_out -----//
  1081. //
  1082. // short_para1 - id. of the firm destroyed.
  1083. // short_para2 - id of the town where the firm is located.
  1084. //
  1085. void News::firm_worn_out()
  1086. {
  1087. //---------------- Text Format -----------------//
  1088. //
  1089. // Your <firm type> near <town name> has fallen into
  1090. // disrepair due to the lack of maintenance funds.
  1091. //
  1092. //----------------------------------------------//
  1093. str = "Your ";
  1094. str += firm_res[short_para1]->name;
  1095. str += " near ";
  1096. str += town_res.get_name(short_para2);
  1097. str += " has fallen into disrepair due to the lack of maintenance funds.";
  1098. }
  1099. //------- End of function News::firm_worn_out -----//
  1100. //------ Begin of function News::chat_msg -----//
  1101. //
  1102. // short_para1 - id. of the chat msg in Info::remote_chat_str_array[]
  1103. //
  1104. // nation_name1() - the nation from which this chat message is sent.
  1105. //
  1106. void News::chat_msg()
  1107. {
  1108. str = info.remote_chat_array[short_para1-1].chat_str;
  1109. }
  1110. //------- End of function News::chat_msg -----//
  1111. //------ Begin of function News::multi_retire -----//
  1112. //
  1113. // This function is called when a human player retires.
  1114. //
  1115. // nation_name1() - the nation that has retired.
  1116. //
  1117. void News::multi_retire()
  1118. {
  1119. //---------------- Text Format -----------------//
  1120. //
  1121. // <Kingdom name> has retired and quited the game.
  1122. //
  1123. //----------------------------------------------//
  1124. str = nation_name1();
  1125. str += " has retired and quited the game.";
  1126. }
  1127. //------- End of function News::multi_retire -----//
  1128. //------ Begin of function News::multi_quit_game -----//
  1129. //
  1130. // This function is called when a human player quits the game.
  1131. //
  1132. void News::multi_quit_game()
  1133. {
  1134. //---------------- Text Format -----------------//
  1135. //
  1136. // <Kingdom name> has quited the game.
  1137. //
  1138. //----------------------------------------------//
  1139. str = nation_name1();
  1140. str += " has quited the game.";
  1141. }
  1142. //------- End of function News::multi_quit_game -----//
  1143. //------ Begin of function News::multi_save_game -----//
  1144. //
  1145. // This function is called when a human player calls for saving the game.
  1146. //
  1147. void News::multi_save_game()
  1148. {
  1149. //---------------- Text Format -----------------//
  1150. //
  1151. // The current game has been saved to <file name>.
  1152. //
  1153. //----------------------------------------------//
  1154. str = "The current game has been saved to ";
  1155. str += remote.save_file_name;
  1156. str += ".";
  1157. }
  1158. //------- End of function News::multi_save_game -----//
  1159. //------ Begin of function News::multi_connection_lost -----//
  1160. //
  1161. // This function is called when a human player's connection has been lost.
  1162. //
  1163. void News::multi_connection_lost()
  1164. {
  1165. //---------------- Text Format -----------------//
  1166. //
  1167. // The connectino with <kingdom name> has been lost.
  1168. //
  1169. //----------------------------------------------//
  1170. str = "The connection with ";
  1171. str += nation_name1();
  1172. str += " has been lost.";
  1173. }
  1174. //------- End of function News::multi_connection_lost -----//
  1175. //------ Begin of function News::nation_name1 -----//
  1176. //
  1177. char* News::nation_name1()
  1178. {
  1179. static String str;
  1180. if( nation_name_id1 < 0 ) // human player - custom name
  1181. str = nation_array.get_human_name(nation_name_id1, 1); // 1-first word of the name only
  1182. else
  1183. str = race_res[nation_race_id1]->get_single_name( (WORD)nation_name_id1 );
  1184. str += "'s Kingdom";
  1185. //------ add color bar -------//
  1186. char colorCodeStr[] = " 0";
  1187. colorCodeStr[1] = FIRST_NATION_COLOR_CODE_IN_TEXT + nation_color1;
  1188. str += colorCodeStr;
  1189. return str;
  1190. }
  1191. //------- End of function News::nation_name1 -----//
  1192. //------ Begin of function News::nation_name2 -----//
  1193. //
  1194. char* News::nation_name2()
  1195. {
  1196. static String str;
  1197. if( nation_name_id2 < 0 ) // human player - custom name
  1198. str = nation_array.get_human_name(nation_name_id2, 1); // 1-first word of the name only
  1199. else
  1200. str = race_res[nation_race_id2]->get_single_name( (WORD)nation_name_id2 );
  1201. str += "'s Kingdom";
  1202. //------ add color bar -------//
  1203. char colorCodeStr[] = " 0";
  1204. colorCodeStr[1] = FIRST_NATION_COLOR_CODE_IN_TEXT + nation_color2;
  1205. str += colorCodeStr;
  1206. return str;
  1207. }
  1208. //------- End of function News::nation_name2 -----//
  1209. //------ Begin of function News::king_name1 -----//
  1210. //
  1211. // [int] addColor - add color bar at the end of the king name
  1212. // (default: 0)
  1213. //
  1214. char* News::king_name1(int addColor)
  1215. {
  1216. static String str;
  1217. if( nation_name_id1 < 0 ) // human player - custom name
  1218. str = nation_array.get_human_name(nation_name_id1);
  1219. else
  1220. str = race_res[nation_race_id1]->get_name( (WORD)nation_name_id1 );
  1221. //------ add color bar -------//
  1222. if( addColor )
  1223. {
  1224. char colorCodeStr[] = " 0";
  1225. colorCodeStr[1] = FIRST_NATION_COLOR_CODE_IN_TEXT + nation_color1;
  1226. str += colorCodeStr;
  1227. }
  1228. return str;
  1229. }
  1230. //------- End of function News::king_name1 -----//
  1231. //------ Begin of function News::king_name2 -----//
  1232. //
  1233. // [int] addColor - add color bar at the end of the king name
  1234. // (default: 0)
  1235. //
  1236. char* News::king_name2(int addColor)
  1237. {
  1238. static String str;
  1239. if( nation_name_id2 < 0 ) // human player - custom name
  1240. str = nation_array.get_human_name(nation_name_id2);
  1241. else
  1242. str = race_res[nation_race_id2]->get_name( (WORD)nation_name_id2 );
  1243. //------ add color bar -------//
  1244. if( addColor )
  1245. {
  1246. char colorCodeStr[] = " 0";
  1247. colorCodeStr[1] = FIRST_NATION_COLOR_CODE_IN_TEXT + nation_color2;
  1248. str += colorCodeStr;
  1249. }
  1250. return str;
  1251. }
  1252. //------- End of function News::king_name2 -----//
  1253. #endif