FOOTBALL.CPP 81 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808
  1. /******************************************************************************
  2. ******************************************************************************/
  3. //
  4. // Actua Soccer. 1.9.94
  5. //
  6. // Programmed by Andy Findlay.
  7. //
  8. /******************************************************************************
  9. ******************************************************************************/
  10. #include <malloc.h>
  11. #include "global.h"
  12. #include "3deng.h"
  13. #include "mouse.h"
  14. #include "editor.h"
  15. #include "time.h"
  16. #include "front.h"
  17. #include "menu.h"
  18. #include "defines.h"
  19. #include "mallocx.h"
  20. #include "eurofrnt\euro_int.h"
  21. extern "C" net_var_start;
  22. extern "C" net_var_end;
  23. extern void init_foul(int fouler,char direct,char see=FALSE);
  24. extern void set_normal_color(int c);
  25. extern int draw_string(buff_info *buff,int font_no,int x,int y,char *string,unsigned char col,short just);
  26. extern int winrange;
  27. extern int Vbytesperline;
  28. extern void mem_test();
  29. extern void setpal();
  30. extern int VESAmode(int *);
  31. extern void VGAmode(unsigned char);
  32. extern void svgacpy(unsigned char *,short,short, short,short);
  33. extern setup_info setup;
  34. extern buff_info main_buff,vidi_buff;
  35. extern match_data match_info;
  36. extern char return_doskey;
  37. extern team_info game_data[];
  38. extern setup_info setup;
  39. extern match_data match_info;
  40. short time_table[]={5,10,20,40,90};
  41. extern unsigned char *readrawfile(char *filename,unsigned char *address);
  42. extern unsigned char pal[768];
  43. extern plyrdat *replay_tab;
  44. //#define NET_A
  45. #include "audio.h" // SOS header
  46. #ifdef ECTS
  47. extern void read_config_file();
  48. #endif
  49. extern "C" volatile int ux1,ux2,wptr,rptr;
  50. extern "C" volatile short net_error;
  51. extern "C" volatile char net_half;
  52. /******************************************************************************
  53. ******************************************************************************/
  54. #include "defines.h"
  55. #include "glob_var.h"
  56. extern void init_off_int(match_player *player);
  57. extern void opendebugfile();
  58. extern void closedebugfile();
  59. extern void writeplayerdata();
  60. extern void writecontroldata(int i);
  61. extern void do_ref_menu();
  62. extern char anykey;
  63. extern float set_camera_height;
  64. extern float set_camera_dist;
  65. extern void out_mcball_coords();
  66. /******************************************************************************
  67. *****************************************************************************/
  68. void checksum()
  69. {
  70. short *v=(short *)&var_start;
  71. short sum=0;
  72. do
  73. {
  74. sum^=*v;
  75. v++;
  76. }while(v<(short *)&var_end);
  77. sprintf(check_str,"%d",sum);
  78. add_message(check_str,WHITE,TRUE);
  79. }
  80. /******************************************************************************
  81. ******************************************************************************/
  82. extern void force_penalty();
  83. int pen_cnt=100;
  84. void make_mtable(int t1,int t2)
  85. {
  86. float d,min_d,x,y,gx;
  87. int p;
  88. for (int j=t2; j<t2+10; j++)
  89. {
  90. teams[j-1].tm_mark=FALSE;
  91. }
  92. if (t2<12)
  93. // Team A goals...
  94. gx=0;
  95. else
  96. // Team B goals...
  97. gx=pitch_len;
  98. for (int a=t1; a>t1-10; a--)
  99. {
  100. // Can't mark guy on ball...
  101. if ((a!=main_man) && (teams[a-1].guy_on>0))
  102. {
  103. x=teams[a-1].tm_x;
  104. y=teams[a-1].tm_y;
  105. p=0;
  106. if (calc_dist(gx-x,cntspot_y-y)<MUST_MARK_DIST)
  107. // Close enough to be a threat!!!
  108. {
  109. min_d=5000;
  110. for (int i=t2; i<t2+10; i++)
  111. {
  112. if ((teams[i-1].guy_on>0) && (!teams[i-1].tm_wall)
  113. && (!teams[i-1].tm_mark))
  114. {
  115. if (i<12)
  116. d=calc_dist(x-match_tactics1[ball_zone1][i-2][0],
  117. y-match_tactics1[ball_zone1][i-2][1]);
  118. else
  119. d=calc_dist((pitch_len-x)-match_tactics2[ball_zone2][i-13][0],
  120. (pitch_wid-y)-match_tactics2[ball_zone2][i-13][1]);
  121. if (d<min_d)
  122. {
  123. min_d=d;
  124. p=i;
  125. }
  126. }
  127. }
  128. }
  129. if (p)
  130. {
  131. d=calc_dist(gx-x,cntspot_y-y);
  132. // How tightly they mark depends on discipline...
  133. x+=(prat*(gx-x)*((192-teams[p-1].tm_disc)/64)/d);
  134. y+=(prat*(cntspot_y-y)*((192-teams[p-1].tm_disc)/64)/d);
  135. teams[p-1].tm_mark=a;
  136. if (p>11)
  137. p-=11;
  138. man2man[p-2][0]=(int)x;
  139. man2man[p-2][1]=(int)y;
  140. }
  141. }
  142. }
  143. }
  144. /******************************************************************************
  145. ******************************************************************************/
  146. extern "C" int deb_x;
  147. extern "C" int deb_y;
  148. void player_stamina()
  149. {
  150. short ir,p;
  151. if (match_time.min!=old_min)
  152. {
  153. old_min=match_time.min;
  154. for (short i=0; i<22; i++)
  155. {
  156. if (!match_info.GameType)
  157. {
  158. int rank;
  159. if ((i<11 && !(match_half&1)) || (i>10 && (match_half&1)))
  160. rank=game_data[setup.team_a].ranking;
  161. else
  162. rank=game_data[setup.team_b].ranking;
  163. ir=50+(1.4*(COUNTRIES-rank-1)); // 50 - 110
  164. }
  165. else
  166. {
  167. if ((i<11 && !(match_half&1)) || (i>10 && (match_half&1)))
  168. {
  169. // Team A...
  170. if (!(match_half&1))
  171. {
  172. p=i;
  173. }
  174. else
  175. {
  176. p=i-11;
  177. }
  178. ir=game_data[setup.team_a].players[p].pace+28;
  179. }
  180. else
  181. {
  182. // Team B...
  183. if (match_half&1)
  184. {
  185. p=i;
  186. }
  187. else
  188. {
  189. p=i-11;
  190. }
  191. ir=game_data[setup.team_b].players[p].pace+28;
  192. }
  193. }
  194. int st=teams[i].tm_stam;
  195. float f=(sin((PI*teams[i].tm_time/120)-(PI/2))+1)/2;
  196. float t=f*(129-st)/140*ir;
  197. teams[i].tm_rate=ir-t;
  198. /*
  199. if ((i==1 && !(match_half&1)) || (i==12 && (match_half&1)))
  200. deb_x=teams[i].tm_rate;
  201. else
  202. if (i==1 || i==12)
  203. deb_y=teams[i].tm_rate;
  204. */
  205. }
  206. }
  207. }
  208. /******************************************************************************
  209. ******************************************************************************/
  210. // Process Various control flags on each logic cycle...
  211. void process_flags()
  212. {
  213. #ifdef EURO96
  214. player_stamina();
  215. #endif
  216. // Text message counter...
  217. if (message_cnt)
  218. if (!(--new_text))
  219. if (--message_cnt)
  220. {
  221. new_text=MESSAGE_TIME;
  222. if (++current_mess==MAX_MESSAGES)
  223. current_mess=0;
  224. }
  225. // Used for offside rule...
  226. if (ball_released)
  227. if (ball_released>0)
  228. ball_released--;
  229. else
  230. ball_released++;
  231. if (play_advantage)
  232. {
  233. // Referee has seen an indiscretion but is waiting to see who collects ball...
  234. if (ball_poss)
  235. {
  236. // Some-one has collected ball!!!
  237. if ((ball_poss<12 && bad_guy>11) || (ball_poss>11 && bad_guy<12))
  238. {
  239. // Favoured team has it!
  240. play_advantage=FALSE;
  241. }
  242. else
  243. {
  244. // Fouling team has it! (no advantage gained!)
  245. retake_foul();
  246. }
  247. }
  248. }
  249. if (just_thrown)
  250. if (last_touch==throw_in_taker)
  251. just_thrown--;
  252. else
  253. just_thrown=FALSE;
  254. switch(match_mode)
  255. {
  256. case(IF_KICK_B):
  257. case(DF_KICK_B):
  258. case(CORNER_TL):
  259. case(CORNER_BL):
  260. man2man_a=TRUE;
  261. man2man_b=FALSE;
  262. break;
  263. case(IF_KICK_A):
  264. case(DF_KICK_A):
  265. case(CORNER_TR):
  266. case(CORNER_BR):
  267. man2man_b=TRUE;
  268. man2man_a=FALSE;
  269. break;
  270. default:
  271. man2man_a=FALSE;
  272. man2man_b=FALSE;
  273. break;
  274. }
  275. if (man2man_b)
  276. // Team B marking table...
  277. {
  278. make_mtable(11,13);
  279. }
  280. else
  281. {
  282. if (man2man_a)
  283. // Team A marking table...
  284. {
  285. make_mtable(22,2);
  286. }
  287. }
  288. }
  289. /******************************************************************************
  290. *****************************************************************************/
  291. void init_line_up()
  292. {
  293. line_up=LINE_UP_DELAY+40;
  294. }
  295. /******************************************************************************
  296. *****************************************************************************/
  297. short convert_control(char c)
  298. {
  299. switch(c)
  300. {
  301. case(0):
  302. return(KEY1_CTRL);
  303. break;
  304. case(1):
  305. return(KEY2_CTRL);
  306. break;
  307. case(2):
  308. return(JOY1_CTRL);
  309. break;
  310. case(3):
  311. return(JOY2_CTRL);
  312. break;
  313. case(4):
  314. return(MOUSE_CTRL);
  315. break;
  316. case(5):
  317. return(LOGPAD_CTRL);
  318. break;
  319. }
  320. return(0);
  321. }
  322. /******************************************************************************
  323. *****************************************************************************/
  324. short conv_conts_back(char c)
  325. {
  326. switch(c)
  327. {
  328. case(JOY1_CTRL):
  329. return(2);
  330. break;
  331. case(JOY2_CTRL):
  332. return(3);
  333. break;
  334. case(KEY1_CTRL):
  335. return(0);
  336. break;
  337. case(KEY2_CTRL):
  338. return(1);
  339. break;
  340. case(MOUSE_CTRL):
  341. return(4);
  342. break;
  343. case(LOGPAD_CTRL):
  344. return(5);
  345. break;
  346. }
  347. return(0);
  348. }
  349. /******************************************************************************
  350. *****************************************************************************/
  351. void init_rand()
  352. {
  353. // Get it from front-end...
  354. srand(EUROmatch_info.rand);
  355. }
  356. /******************************************************************************
  357. *****************************************************************************/
  358. void get_performance()
  359. {
  360. short p,max_p1,max_p2,min_p1,min_p2,min_p,sp,spa,spb;
  361. float clock=45./time_factor;
  362. for (short i=0; i<22; i++)
  363. {
  364. p=0;
  365. if (teams[i].tm_time>=15)
  366. {
  367. if (!i || i==(KP_B-1))
  368. {
  369. // Keeper performance...
  370. p+=PER_KPSAVES*clock*teams[i].tm_kpsaves;
  371. p+=PER_GOALSIN*clock*(i<11 ? team_a_goals:team_b_goals);
  372. }
  373. p+=PER_BOOKINGS*clock*teams[i].tm_book;
  374. p+=PER_FOULS*clock*teams[i].tm_fouls;
  375. p+=PER_GOALS*clock*teams[i].tm_goals;
  376. p+=PER_OGS*clock*teams[i].tm_ogs;
  377. p+=PER_POSS*clock*teams[i].tm_posst;
  378. p+=PER_WORK*clock*teams[i].tm_work;
  379. if (teams[i].tm_tacks)
  380. p+=PER_TACKS*teams[i].tm_twon/(teams[i].tm_tacks+10/clock);
  381. if (teams[i].tm_shots)
  382. p+=PER_SHOTS*teams[i].tm_saved/(teams[i].tm_shots+10/clock);
  383. if (teams[i].tm_pass)
  384. p+=PER_PASSES*teams[i].tm_pwon/(teams[i].tm_pass+10/clock);
  385. }
  386. else
  387. // Not been on field long enough...
  388. p=-2000;
  389. performance[i]=p;
  390. }
  391. max_p1=-1000;
  392. max_p2=-1000;
  393. min_p1=1000;
  394. min_p2=1000;
  395. for (i=0; i<22; i++)
  396. {
  397. p=performance[i];
  398. if (i>10)
  399. {
  400. if (p>max_p1)
  401. {
  402. max_p1=p;
  403. spa=i+1;
  404. }
  405. if (p<min_p1)
  406. min_p1=p;
  407. }
  408. if (i<11)
  409. {
  410. if (p>max_p2)
  411. {
  412. max_p2=p;
  413. spb=i+1;
  414. }
  415. if (p<min_p2)
  416. min_p2=p;
  417. }
  418. }
  419. if (max_p1>max_p2)
  420. {
  421. sp=max_p1;
  422. man_of_match=spa;
  423. }
  424. else
  425. {
  426. sp=max_p2;
  427. man_of_match=spb;
  428. }
  429. if (min_p1<min_p2)
  430. min_p=min_p1;
  431. else
  432. min_p=min_p2;
  433. sp-=min_p;
  434. // Performance is a percentage of star players...
  435. for (i=0; i<22; i++)
  436. {
  437. p=performance[i];
  438. performance[i]=100.*(p-min_p)/sp;
  439. }
  440. }
  441. /******************************************************************************
  442. *****************************************************************************/
  443. // Initialise zero vars...
  444. extern char cross_on;
  445. extern "C" short state_checksum;
  446. void initialise_vars()
  447. {
  448. int i;
  449. for (i=0; i<5; i++)
  450. {
  451. burst_timer[i]=0;
  452. }
  453. for (i=0; i<22; i++)
  454. {
  455. sel_circle[i]=0;
  456. }
  457. #ifdef EURO96
  458. state_checksum=0;
  459. state_ptr=&state1;
  460. checksum_ptr=(short *)state_ptr;
  461. #endif
  462. escape_pending=0;
  463. man_of_match=0;
  464. xinfo=0;
  465. message_cnt=0;
  466. current_mess=0;
  467. new_text=0;
  468. not_ahead=FALSE;
  469. kick_off=TRUE;
  470. forced=0;
  471. keep_timer=0;
  472. player_on_off=FALSE;
  473. player_being_subbed=FALSE;
  474. sub_pending=FALSE;
  475. booking=FALSE;
  476. stop_clock=FALSE;
  477. card_is_out=0;
  478. anykey=FALSE;
  479. demo_match=FALSE;
  480. rolling_clock=0;
  481. keep_dive=FALSE;
  482. hold_up_play=0;
  483. cross_on=FALSE;
  484. wall_is_up=FALSE;
  485. comsetp=0;
  486. init_rand();
  487. // Timing Vars...
  488. updates=0;
  489. old_count=0;
  490. crowd_mood_a=0;
  491. crowd_mood_b=0;
  492. possession=0;
  493. poss_held=0;
  494. for (i=0; i<11; i++)
  495. {
  496. strike[i].t=0;
  497. strike[i].free=0;
  498. strike[i].ptype=0;
  499. strike[i].pplr=0;
  500. strike[i].gt=0;
  501. strike[i].x=0;
  502. strike[i].y=0;
  503. strike[i].atime=0;
  504. strike[i].stop=0;
  505. }
  506. first_time_it=FALSE;
  507. auto_select=FALSE;
  508. seconds=0;
  509. arrow_on=0;
  510. logic_cnt=0;
  511. ball_move=FALSE;
  512. first_bounce=0;
  513. swerve=0;
  514. spin_cnt=0;
  515. spin_ball=0;
  516. prediction=FALSE;
  517. set_xyspin=0;
  518. set_zspin=0;
  519. ball_horz_ang=0;
  520. ball_vert_ang=0;
  521. max_sw_factor=0;
  522. swerve_factor=0;
  523. rebound_ball=0;
  524. headed_ball=0;
  525. say_names=TRUE;
  526. fired_a_shot=0;
  527. comm_pass=0;
  528. comm_pass_type=0;
  529. keeper_spd=0;
  530. keeper_down=FALSE;
  531. save_direction=FALSE;
  532. keeper_will_save=FALSE;
  533. keeper_on_grnd=FALSE;
  534. keeper_contact=0;
  535. ball_in_goal=FALSE;
  536. ball_in_hands=FALSE;
  537. game_action=FALSE;
  538. throw_cnt=0;
  539. team_a_goals=0;
  540. team_b_goals=0;
  541. last_goal=0;
  542. scorer_running=FALSE;
  543. just_scored=0;
  544. just_thrown=0;
  545. goal_scorer=0;
  546. pass_type=0;
  547. kick_type=0;
  548. receiver=0;
  549. cross_now=0;
  550. must_face=FALSE;
  551. must_face_time=0;
  552. must_face_x=0;
  553. must_face_y=0;
  554. must_shoot=FALSE;
  555. chip_pass=FALSE;
  556. must_pass=FALSE;
  557. must_punt=FALSE;
  558. keeper_a_in_box=0;
  559. keeper_b_in_box=0;
  560. keeper_steps=0;
  561. save_block=0;
  562. save_xoff=0;
  563. save_yoff=0;
  564. save_zoff=0;
  565. shot_speed=0;
  566. scr_x=0;
  567. scr_y=0;
  568. ball_speed=0;
  569. ball_int_speed=0;
  570. interceptor_a=0;
  571. interceptor_b=0;
  572. in_cross_area=0;
  573. close_in_number=0;
  574. shooter=0;
  575. ball_inair=1;
  576. super_shot=0;
  577. opponents_near_holder=0;
  578. opponents_really_close=0;
  579. int ball_poss=0;
  580. sender_1_2=0;
  581. ball_still=0;
  582. last_touch=0;
  583. want_pass=0;
  584. before=0;
  585. support_me=0;
  586. pre_kp_touch=0;
  587. prev_touch=0;
  588. ball_limbo_p=0;
  589. ball_limbo_on=FALSE;
  590. ball_limbo_c=0;
  591. ball_released=0;
  592. cannot_pick_up=0;
  593. last_user_a=0;
  594. last_user_b=0;
  595. last_plr_a=0;
  596. last_plr_b=0;
  597. players_off_a=0;
  598. players_off_b=0;
  599. want_pass_stat=0;
  600. ball_zone1=0;
  601. ball_zone2=0;
  602. ball_out_of_play=0;
  603. receiver_a=0;
  604. receiver_b=0;
  605. ready_centre=0;
  606. shot_attempt=0;
  607. force_select=0;
  608. heading_ball=0;
  609. flag=0;
  610. rep_camera=0;
  611. sub_camera=0;
  612. allow_replay=0;
  613. replay_pos=0;
  614. old_rep_pos=0;
  615. replay_cnt=0;
  616. pitch_sprs=0;
  617. fixed_net_user=0;
  618. memset(&auto_users_list_a,0,sizeof(auto_users_list_a));
  619. memset(&auto_users_list_b,0,sizeof(auto_users_list_b));
  620. auto_users_a=0;
  621. auto_users_b=0;
  622. play_ball_a=0;
  623. play_ball_b=0;
  624. new_select=0;
  625. auto_intercept=0;
  626. closest=0;
  627. f1_down=0;
  628. f2_down=0;
  629. spec_kick_type=0;
  630. setp_hgt=0;
  631. setp_power=0;
  632. setp_kick_x=0;
  633. setp_kick_y=0;
  634. setp_bxd=0;
  635. setp_byd=0;
  636. setp_bzd=0;
  637. user_taker=0;
  638. user_controlled=0;
  639. user_plr=0;
  640. after_touch_on=FALSE;
  641. drive_shot=0;
  642. wallx=0;
  643. wally=0;
  644. men_in_wall=0;
  645. for (i=0; i<5; i++)
  646. {
  647. wguys[i].guy=0;
  648. wguys[i].x=0;
  649. wguys[i].y=0;
  650. }
  651. keeper_pos_x=0;
  652. keeper_pos_y=0;
  653. centre_guy_1=0;
  654. centre_guy_2=0;
  655. in_range=0;
  656. in_header_rng=0;
  657. in_shot_rng=0;
  658. taker_x=0;
  659. taker_y=0;
  660. bad_guy=0;
  661. direct_fk=FALSE;
  662. play_advantage=0;
  663. set_piece_on=0;
  664. shot_acknowledged=FALSE;
  665. shot_pending=FALSE;
  666. real_shot=FALSE;
  667. shot_missed=0;
  668. shot_saved=0;
  669. for (i=0; i<10; i++)
  670. {
  671. opp_dir_tab[i][0]=0;
  672. opp_dir_tab[i][1]=0;
  673. opp_dir_tab[i][2]=0;
  674. }
  675. offside_now=0;
  676. memset(&tussle_tab,0,sizeof(tussle_tab));
  677. ball_travel=0;
  678. select_cnt=10;
  679. in_game=1;
  680. analogue=1;
  681. ballxdis=12.0, ballydis=2.0, ballzdis=10.0;
  682. ballx=cntspot_x, bally=cntspot_y, ballz=ball_diam/2;
  683. prev_ballx=0.0*16, prev_bally=30.0*16, prev_ballz=ball_diam/2;
  684. ns_ballx=0.0, ns_bally=0.0, ns_ballz=ball_diam/2;
  685. ball_zspin=0;
  686. ball_xyspin=0;
  687. full_zspin=0;
  688. full_xyspin=0;
  689. shoot_x=0;
  690. shoot_y=0;
  691. nearest_a=0,nearest_b=0,old_ltouch=-1,old_ball_poss=-1;
  692. use_ball_limit=0;
  693. near_path_a=0;
  694. near_path_b=0;
  695. zone1_x=0;
  696. zone2_x=0;
  697. zone1_y=0;
  698. zone2_y=0;
  699. incident_x=0;
  700. incident_y=0;
  701. difficulty=0;
  702. match_mode=0;
  703. dead_ball_cnt=0;
  704. defense_a=0;
  705. defense_b=0;
  706. poss_mode=0;
  707. for (i=0; i<50; i++)
  708. {
  709. ball_pred_tab[i][0]=ballx;
  710. ball_pred_tab[i][1]=bally;
  711. ball_pred_tab[i][2]=ballz;
  712. ns_ball_pred_tab[i][0]=ballx;
  713. ns_ball_pred_tab[i][1]=bally;
  714. ns_ball_pred_tab[i][2]=ballz;
  715. }
  716. delay_cnt=40;
  717. play_nums_on=0;
  718. frame=FALSE;
  719. frames=0;
  720. frms_per_sec=0;
  721. last_second=0;
  722. old_clock=0;
  723. }
  724. /******************************************************************************
  725. *****************************************************************************/
  726. void init_user_controls()
  727. {
  728. #ifdef FRONT_END
  729. num_of_users=0;
  730. #endif
  731. short home_plrs=EUROmatch_info.TeamA_users;
  732. short away_plrs=EUROmatch_info.TeamB_users;
  733. /*
  734. short home_plrs=game_data[setup.team_a].player_control;
  735. short away_plrs=game_data[setup.team_b].player_control;
  736. */
  737. short plrs=0;
  738. short c;
  739. short pnum=0;
  740. for (short i=1; i<16; i<<=1)
  741. {
  742. pnum++;
  743. if (home_plrs&i)
  744. {
  745. // User...
  746. plrs++;
  747. c=convert_control(EUROmatch_info.CntrlTypes[pnum-1]);
  748. add_team_user(-1,c);
  749. }
  750. if (away_plrs&i)
  751. {
  752. // User...
  753. plrs++;
  754. c=convert_control(EUROmatch_info.CntrlTypes[pnum-1]);
  755. add_team_user(-2,c);
  756. }
  757. }
  758. }
  759. /******************************************************************************
  760. *****************************************************************************/
  761. // Copy buffer to current VESA screen
  762. void svgacpy2(unsigned char *buffpt,short x,short y,short w,short h)
  763. {
  764. union REGS regs;
  765. short i,co;
  766. char *scrpt;
  767. int scrdisp=x+Vbytesperline*y;
  768. char bank=scrdisp/winrange;
  769. scrdisp%=winrange;
  770. scrpt=(char *)0xa0000+scrdisp;
  771. regs.x.eax=0x4f05;
  772. regs.x.ebx=0;
  773. regs.x.edx=bank;
  774. int386(16,&regs,&regs);
  775. do
  776. {
  777. co=MIN((winrange-scrdisp)/Vbytesperline,h);
  778. for (i=0;i<co;i++)
  779. {
  780. memcpy(scrpt,buffpt,640);
  781. scrpt+=Vbytesperline;
  782. buffpt+=640;
  783. h--;
  784. }
  785. if (h)
  786. {
  787. scrdisp=(scrdisp+(co+1)*Vbytesperline)%winrange;
  788. co=MIN(Vbytesperline-scrdisp,w);
  789. memcpy(scrpt,buffpt,co);
  790. bank++;
  791. regs.x.eax=0x4f05;
  792. regs.x.ebx=0;
  793. regs.x.edx=bank;
  794. int386(16,&regs,&regs);
  795. if (co!=w)
  796. memcpy((char *)0xa0000,buffpt+co,w-co);
  797. scrpt=(char *)0xa0000+scrdisp;
  798. buffpt+=640;
  799. h--;
  800. }
  801. }while (h);
  802. regs.x.eax=0x4f05;
  803. regs.x.ebx=0;
  804. regs.x.edx=0;
  805. int386(16,&regs,&regs);
  806. }
  807. /******************************************************************************
  808. *****************************************************************************/
  809. void display_endscr()
  810. {
  811. int vesas[]={0x101,-1};
  812. unsigned char *scr=(unsigned char *)mallocx(640*480);
  813. readrawfile("rolling.pal",(unsigned char *)pal); // Laurent's
  814. VESAmode(vesas);
  815. readrawfile("rolling.bm",scr);
  816. svgacpy2(scr,0,0,640,480);
  817. setpal();
  818. return_doskey=TRUE;
  819. getch();
  820. freex(scr);
  821. }
  822. /******************************************************************************
  823. *****************************************************************************/
  824. void display_screen()
  825. {
  826. int vesas[]={0x101,-1};
  827. int svesas[]={0x100,-1};
  828. unsigned char spal[768];
  829. memcpy(spal,pal,768);
  830. readrawfile("andy.pal",(unsigned char *)pal); // Laurent's
  831. unsigned short x,y;
  832. unsigned char sw;
  833. VESAmode(vesas);
  834. readrawfile("andy.bm",(unsigned char *)main_buff.buff_start);
  835. svgacpy2(main_buff.buff_start,0,0,640,480);
  836. setpal();
  837. count=1;
  838. do{
  839. read_joystick(0,&x,&y,&sw);
  840. if (!--count)
  841. {
  842. count=200;
  843. pal[768-6]--;
  844. pal[768-5]--;
  845. pal[768-4]--;
  846. setpal();
  847. }
  848. }while(!sw);
  849. #ifndef ONE_MACHINE
  850. VGAmode(0x13);
  851. #else
  852. VESAmode(svesas);
  853. #endif
  854. memcpy(pal,spal,768);
  855. setpal();
  856. }
  857. /******************************************************************************
  858. *****************************************************************************/
  859. void load_new_tactics()
  860. {
  861. FILE *fp1;
  862. if (tactics_a!=old_tac_a)
  863. {
  864. // Load Match tactics...
  865. switch(tactics_a)
  866. {
  867. case(F_4_3_3):
  868. fp1=fopen("tac_433.tac","rb");
  869. break;
  870. case(F_5_3_2):
  871. fp1=fopen("tac_532.tac","rb");
  872. break;
  873. case(F_6_3_1):
  874. fp1=fopen("tac_631.tac","rb");
  875. break;
  876. case(F_4_2_4):
  877. fp1=fopen("tac_424.tac","rb");
  878. break;
  879. case(F_5_1_4):
  880. fp1=fopen("tac_514.tac","rb");
  881. break;
  882. case(F_4_0_6):
  883. fp1=fopen("tac_406.tac","rb");
  884. break;
  885. case(F_3_1_6):
  886. fp1=fopen("tac_316.tac","rb");
  887. break;
  888. case(F_4_1_5):
  889. fp1=fopen("tac_415.tac","rb");
  890. break;
  891. case(F_5_2_3):
  892. fp1=fopen("tac_523.tac","rb");
  893. break;
  894. case(F_4_4_2):
  895. fp1=fopen("tac_442.tac","rb");
  896. break;
  897. }
  898. // Team A tactics...
  899. if (!(match_half&1))
  900. fread(match_tactics1,sizeof(int),((32*2)+6)*10*2,fp1);
  901. else
  902. fread(match_tactics2,sizeof(int),((32*2)+6)*10*2,fp1);
  903. fclose(fp1);
  904. }
  905. if (tactics_b!=old_tac_b)
  906. {
  907. // Load Match tactics...
  908. switch(tactics_b)
  909. {
  910. case(F_4_3_3):
  911. fp1=fopen("tac_433.tac","rb");
  912. break;
  913. case(F_5_3_2):
  914. fp1=fopen("tac_532.tac","rb");
  915. break;
  916. case(F_6_3_1):
  917. fp1=fopen("tac_631.tac","rb");
  918. break;
  919. case(F_4_2_4):
  920. fp1=fopen("tac_424.tac","rb");
  921. break;
  922. case(F_5_1_4):
  923. fp1=fopen("tac_514.tac","rb");
  924. break;
  925. case(F_4_0_6):
  926. fp1=fopen("tac_406.tac","rb");
  927. break;
  928. case(F_3_1_6):
  929. fp1=fopen("tac_316.tac","rb");
  930. break;
  931. case(F_4_1_5):
  932. fp1=fopen("tac_415.tac","rb");
  933. break;
  934. case(F_5_2_3):
  935. fp1=fopen("tac_523.tac","rb");
  936. break;
  937. case(F_4_4_2):
  938. fp1=fopen("tac_442.tac","rb");
  939. break;
  940. }
  941. // Team B tactics...
  942. if (!(match_half&1))
  943. fread(match_tactics2,sizeof(int),((32*2)+6)*10*2,fp1);
  944. else
  945. fread(match_tactics1,sizeof(int),((32*2)+6)*10*2,fp1);
  946. fclose(fp1);
  947. }
  948. old_tac_a=tactics_a;
  949. old_tac_b=tactics_b;
  950. }
  951. /******************************************************************************
  952. *****************************************************************************/
  953. void init_match()
  954. {
  955. sub_pending=0;
  956. key_togs[0x0a]=EUROmatch_info.vidi;
  957. // Initialise Penalty Shoot-out...
  958. penalties=0;
  959. home_pens_left=5;
  960. away_pens_left=5;
  961. penalty_game=FALSE;
  962. penalty_team=FALSE;
  963. penalty_counter=0;
  964. pen_taker_a=11;
  965. pen_taker_b=22;
  966. first_update=TRUE;
  967. reset_ball();
  968. opt_user=0;
  969. subbing_now=FALSE;
  970. if (setup.M8)
  971. replay_seconds=15;
  972. else
  973. replay_seconds=0;
  974. if (replay_seconds)
  975. {
  976. replay_tab=(plyrdat *)mallocx(replay_seconds*ncb*20*sizeof(plyrdat));
  977. if (replay_tab==NULL)
  978. {
  979. printf("Ooops... Can't malloc replay buffer!\n");
  980. exit(-1);
  981. }
  982. }
  983. auto_intercept=TRUE;
  984. end_game=FALSE;
  985. allow_replay=FALSE;
  986. match_time.min=0;
  987. match_time.sec=0;
  988. next_mins=0;
  989. just_scored=0;
  990. set_piece_on=0;
  991. team_a_goals=0;
  992. team_b_goals=0;
  993. if (!network_on)
  994. init_user_controls();
  995. need_result=(match_info.CompetitionType==2);
  996. clock_running=FALSE;
  997. team_a=0;
  998. team_b=1;
  999. match_half=0;
  1000. last_centre=0;
  1001. init_line_up();
  1002. // Ects show demo (head to head)...
  1003. #ifdef ECTS
  1004. read_config_file();
  1005. display_screen();
  1006. #endif
  1007. /*** Setup Tactics ***/
  1008. tactics_a=EUROmatch_info.tac_1;
  1009. tactics_b=EUROmatch_info.tac_2;
  1010. old_tac_a=-1; // Force new tactical load!
  1011. old_tac_b=-1;
  1012. load_new_tactics();
  1013. ref_accuracy=EUROmatch_info.referee_vision;
  1014. ref_strictness=EUROmatch_info.referee_discipline;
  1015. }
  1016. /******************************************************************************
  1017. ******************************************************************************/
  1018. #define COUNTRIES 44
  1019. void init_player_stats(short p)
  1020. {
  1021. p--;
  1022. short ps;
  1023. if ((!(match_half&1) && p<11)
  1024. || (match_half&1 && p>10))
  1025. {
  1026. // Team A...
  1027. if (!(match_half&1))
  1028. {
  1029. ps=p;
  1030. }
  1031. else
  1032. {
  1033. ps=p-11;
  1034. }
  1035. if (match_info.GameType)
  1036. {
  1037. // Simulation Mode!!!
  1038. teams[p].tm_rate=game_data[setup.team_a].players[ps].pace+28;
  1039. teams[p].tm_pow=game_data[setup.team_a].players[ps].power+28;
  1040. teams[p].tm_cont=game_data[setup.team_a].players[ps].control+28;
  1041. teams[p].tm_flair=game_data[setup.team_a].players[ps].flair+28;
  1042. teams[p].tm_vis=game_data[setup.team_a].players[ps].vision+28;
  1043. teams[p].tm_ac=game_data[setup.team_a].players[ps].accuracy+28;
  1044. teams[p].tm_stam=game_data[setup.team_a].players[ps].stamina+28;
  1045. teams[p].tm_disc=game_data[setup.team_a].players[ps].discipline+28;
  1046. }
  1047. else
  1048. {
  1049. // Arcade Mode!!!
  1050. int rank=game_data[setup.team_a].ranking;
  1051. short avg=50+(1.4*(COUNTRIES-rank-1)); // 50 - 110
  1052. teams[p].tm_rate=30+(avg/2);
  1053. teams[p].tm_pow=avg;
  1054. teams[p].tm_cont=avg;
  1055. teams[p].tm_flair=avg;
  1056. teams[p].tm_vis=avg;
  1057. teams[p].tm_ac=avg;
  1058. teams[p].tm_stam=avg;
  1059. teams[p].tm_disc=avg;
  1060. }
  1061. }
  1062. else
  1063. {
  1064. // Team B...
  1065. if (match_half&1)
  1066. {
  1067. ps=p;
  1068. }
  1069. else
  1070. {
  1071. ps=p-11;
  1072. }
  1073. if (match_info.GameType)
  1074. {
  1075. // Simulation Mode!!!
  1076. teams[p].tm_rate=game_data[setup.team_b].players[ps].pace+28;
  1077. teams[p].tm_pow=game_data[setup.team_b].players[ps].power+28;
  1078. teams[p].tm_cont=game_data[setup.team_b].players[ps].control+28;
  1079. teams[p].tm_flair=game_data[setup.team_b].players[ps].flair+28;
  1080. teams[p].tm_vis=game_data[setup.team_b].players[ps].vision+28;
  1081. teams[p].tm_ac=game_data[setup.team_b].players[ps].accuracy+28;
  1082. teams[p].tm_stam=game_data[setup.team_b].players[ps].stamina+28;
  1083. teams[p].tm_disc=game_data[setup.team_b].players[ps].discipline+28;
  1084. }
  1085. else
  1086. {
  1087. // Arcade Mode!!!
  1088. int rank=game_data[setup.team_b].ranking;
  1089. short avg=50+(1.4*(COUNTRIES-rank-1)); // 50 - 110
  1090. teams[p].tm_rate=30+(avg/2);
  1091. teams[p].tm_pow=avg;
  1092. teams[p].tm_cont=avg;
  1093. teams[p].tm_flair=avg;
  1094. teams[p].tm_vis=avg;
  1095. teams[p].tm_ac=avg;
  1096. teams[p].tm_stam=avg;
  1097. teams[p].tm_disc=avg;
  1098. }
  1099. }
  1100. }
  1101. /******************************************************************************
  1102. ******************************************************************************/
  1103. void process_subs()
  1104. {
  1105. if (player_being_subbed)
  1106. {
  1107. // Player has been selected and should come off!
  1108. if (!teams[player_being_subbed-1].guy_on)
  1109. {
  1110. // He's off the park... (Bring on new guy!)
  1111. init_player_stats(player_being_subbed);
  1112. teams[player_being_subbed-1].shirt=player_coming_on;
  1113. teams[player_being_subbed-1].tm_trap=FALSE;
  1114. teams[player_being_subbed-1].int_move=FALSE;
  1115. teams[player_being_subbed-1].int_cnt=FALSE;
  1116. reset_ideas(&teams[player_being_subbed-1]);
  1117. player_being_subbed=FALSE;
  1118. teams[player_on_off-1].guy_on=TRUE;
  1119. player_on_off=-player_on_off; // Coming on!
  1120. init_off_int(&teams[(-player_on_off)-1]);
  1121. }
  1122. }
  1123. else
  1124. {
  1125. if (!player_on_off && sub_pending && (match_mode>=CORNER_TL && match_mode<=DF_KICK_B)
  1126. && !kickoff)
  1127. {
  1128. opt_user=100; // Substitute instead of options...
  1129. // Some-one is trying to make a substitution...(Who?)
  1130. if (sub_pending&1)
  1131. opt_team=0;
  1132. else
  1133. opt_team=1;
  1134. }
  1135. }
  1136. }
  1137. /******************************************************************************
  1138. ******************************************************************************/
  1139. void save_state(save_data *save_it)
  1140. {
  1141. memcpy(save_it->teams,teams,sizeof(teams));
  1142. memcpy(&save_it->match_time,&match_time,sizeof(match_time));
  1143. memcpy(save_it->refs,refs,sizeof(refs));
  1144. memcpy(save_it->speech_tab,speech_tab,sizeof(speech_tab));
  1145. memcpy(save_it->wguys,wguys,sizeof(wguys));
  1146. memcpy(save_it->sel_circle,sel_circle,sizeof(sel_circle));
  1147. memcpy(save_it->burst_timer,burst_timer,sizeof(burst_timer));
  1148. memcpy(save_it->auto_users_list_a,auto_users_list_a,sizeof(auto_users_list_a));
  1149. memcpy(save_it->auto_users_list_b,auto_users_list_b,sizeof(auto_users_list_b));
  1150. memcpy(save_it->rand1_tab,rand1_tab,sizeof(rand1_tab));
  1151. memcpy(save_it->rand2_tab,rand2_tab,sizeof(rand2_tab));
  1152. memcpy(save_it->man2man,man2man,sizeof(man2man));
  1153. memcpy(save_it->glob_str1,glob_str1,sizeof(glob_str1));
  1154. memcpy(save_it->glob_str2,glob_str2,sizeof(glob_str2));
  1155. save_it->sub_pending=sub_pending;
  1156. save_it->return_12=return_12;
  1157. save_it->shamed_player=shamed_player;
  1158. save_it->old_min=old_min;
  1159. save_it->users_left=users_left;
  1160. save_it->setp_x=setp_x;
  1161. save_it->setp_y=setp_y;
  1162. save_it->setp_wait_cnt=setp_wait_cnt;
  1163. save_it->frame=frame;
  1164. save_it->kick_off=kick_off;
  1165. save_it->keep_timer=keep_timer;
  1166. save_it->stop_clock=stop_clock;
  1167. save_it->keep_dive=keep_dive;
  1168. save_it->hold_up_play=hold_up_play;
  1169. save_it->wall_is_up=wall_is_up;
  1170. save_it->card_is_out=card_is_out;
  1171. save_it->crowd_mood_a=crowd_mood_a;
  1172. save_it->crowd_mood_b=crowd_mood_b;
  1173. save_it->possession=possession;
  1174. save_it->poss_held=poss_held;
  1175. save_it->arrow_on=arrow_on;
  1176. save_it->logic_cnt=logic_cnt;
  1177. save_it->ball_move=ball_move;
  1178. save_it->first_bounce=first_bounce;
  1179. save_it->swerve=swerve;
  1180. save_it->spin_cnt=spin_cnt;
  1181. save_it->spin_ball=spin_ball;
  1182. save_it->prediction=prediction;
  1183. save_it->set_xyspin=set_xyspin;
  1184. save_it->set_zspin=set_zspin;
  1185. save_it->ball_horz_ang=ball_horz_ang;
  1186. save_it->ball_vert_ang=ball_vert_ang;
  1187. save_it->max_sw_factor=max_sw_factor;
  1188. save_it->swerve_factor=swerve_factor;
  1189. save_it->rebound_ball=rebound_ball;
  1190. save_it->headed_ball=headed_ball;
  1191. save_it->say_names=say_names;
  1192. save_it->fired_a_shot=fired_a_shot;
  1193. save_it->comm_pass=comm_pass;
  1194. save_it->comm_pass_type=comm_pass_type;
  1195. save_it->keeper_spd=keeper_spd;
  1196. save_it->keeper_down=keeper_down;
  1197. save_it->save_direction=save_direction;
  1198. save_it->keeper_will_save=keeper_will_save;
  1199. save_it->keeper_on_grnd=keeper_on_grnd;
  1200. save_it->keeper_contact=keeper_contact;
  1201. save_it->ball_in_goal=ball_in_goal;
  1202. save_it->ball_in_hands=ball_in_hands;
  1203. save_it->game_action=game_action;
  1204. save_it->throw_cnt=throw_cnt;
  1205. save_it->team_a_goals=team_a_goals;
  1206. save_it->team_b_goals=team_b_goals;
  1207. save_it->last_goal=last_goal;
  1208. save_it->scorer_running=scorer_running;
  1209. save_it->just_scored=just_scored;
  1210. save_it->just_thrown=just_thrown;
  1211. save_it->goal_scorer=goal_scorer;
  1212. save_it->pass_type=pass_type;
  1213. save_it->kick_type=kick_type;
  1214. save_it->receiver=receiver;
  1215. save_it->cross_now=cross_now;
  1216. save_it->auto_select=auto_select;
  1217. save_it->must_face=must_face;
  1218. save_it->must_face_time=must_face_time;
  1219. save_it->must_face_x=must_face_x;
  1220. save_it->must_face_y=must_face_y;
  1221. save_it->must_shoot=must_shoot;
  1222. save_it->chip_pass=chip_pass;
  1223. save_it->must_pass=must_pass;
  1224. save_it->must_punt=must_punt;
  1225. save_it->keeper_a_in_box=keeper_a_in_box;
  1226. save_it->keeper_b_in_box=keeper_b_in_box;
  1227. save_it->keeper_steps=keeper_steps;
  1228. save_it->save_block=save_block;
  1229. save_it->save_xoff=save_xoff;
  1230. save_it->save_yoff=save_yoff;
  1231. save_it->save_zoff=save_zoff;
  1232. save_it->shot_speed=shot_speed;
  1233. save_it->scr_x=scr_x;
  1234. save_it->scr_y=scr_y;
  1235. save_it->ball_speed=ball_speed;
  1236. save_it->ball_int_speed=ball_int_speed;
  1237. save_it->interceptor_a=interceptor_a;
  1238. save_it->interceptor_b=interceptor_b;
  1239. save_it->in_cross_area=in_cross_area;
  1240. save_it->close_in_number=close_in_number;
  1241. save_it->shooter=shooter;
  1242. save_it->ball_inair=ball_inair;
  1243. save_it->super_shot=super_shot;
  1244. save_it->opponents_near_holder=opponents_near_holder;
  1245. save_it->opponents_really_close=opponents_really_close;
  1246. save_it->ball_poss=ball_poss;
  1247. save_it->sender_1_2=sender_1_2;
  1248. save_it->ball_still=ball_still;
  1249. save_it->last_touch=last_touch;
  1250. save_it->want_pass=want_pass;
  1251. save_it->before=before;
  1252. save_it->support_me=support_me;
  1253. save_it->pre_kp_touch=pre_kp_touch;
  1254. save_it->prev_touch=prev_touch;
  1255. save_it->ball_limbo_p=ball_limbo_p;
  1256. save_it->ball_limbo_on=ball_limbo_on;
  1257. save_it->ball_limbo_c=ball_limbo_c;
  1258. save_it->ball_released=ball_released;
  1259. save_it->cannot_pick_up=cannot_pick_up;
  1260. save_it->forced=forced;
  1261. save_it->last_user_a=last_user_a;
  1262. save_it->last_user_b=last_user_b;
  1263. save_it->last_plr_a=last_plr_a;
  1264. save_it->last_plr_b=last_plr_b;
  1265. save_it->players_off_a=players_off_a;
  1266. save_it->players_off_b=players_off_b;
  1267. save_it->want_pass_stat=want_pass_stat;
  1268. save_it->ball_zone1=ball_zone1;
  1269. save_it->ball_zone2=ball_zone2;
  1270. save_it->ball_out_of_play=ball_out_of_play;
  1271. save_it->receiver_a=receiver_a;
  1272. save_it->receiver_b=receiver_b;
  1273. save_it->ready_centre=ready_centre;
  1274. save_it->shot_attempt=shot_attempt;
  1275. save_it->force_select=force_select;
  1276. save_it->heading_ball=heading_ball;
  1277. save_it->flag=flag;
  1278. save_it->rep_camera=rep_camera;
  1279. save_it->sub_camera=sub_camera;
  1280. save_it->allow_replay=allow_replay;
  1281. save_it->replay_pos=replay_pos;
  1282. save_it->old_rep_pos=old_rep_pos;
  1283. save_it->replay_cnt=replay_cnt;
  1284. save_it->pitch_sprs=pitch_sprs;
  1285. save_it->lp_user=lp_user;
  1286. save_it->fixed_net_user=fixed_net_user;
  1287. save_it->auto_users_a=auto_users_a;
  1288. save_it->auto_users_b=auto_users_b;
  1289. save_it->play_ball_a=play_ball_a;
  1290. save_it->play_ball_b=play_ball_b;
  1291. save_it->new_select=new_select;
  1292. save_it->auto_intercept=auto_intercept;
  1293. save_it->closest=closest;
  1294. save_it->f1_down=f1_down;
  1295. save_it->f2_down=f2_down;
  1296. save_it->spec_kick_type=spec_kick_type;
  1297. save_it->setp_hgt=setp_hgt;
  1298. save_it->setp_power=setp_power;
  1299. save_it->setp_kick_x=setp_kick_x;
  1300. save_it->setp_kick_y=setp_kick_y;
  1301. save_it->setp_bxd=setp_bxd;
  1302. save_it->setp_byd=setp_byd;
  1303. save_it->setp_bzd=setp_bzd;
  1304. save_it->user_taker=user_taker;
  1305. save_it->user_taker2=user_taker2;
  1306. save_it->user_controlled=user_controlled;
  1307. save_it->user_plr=user_plr;
  1308. save_it->after_touch_on=after_touch_on;
  1309. save_it->drive_shot=drive_shot;
  1310. save_it->newk_shot=newk_shot;
  1311. save_it->wallx=wallx;
  1312. save_it->wally=wally;
  1313. save_it->men_in_wall=men_in_wall;
  1314. save_it->keeper_pos_x=keeper_pos_x;
  1315. save_it->keeper_pos_y=keeper_pos_y;
  1316. save_it->centre_guy_1=centre_guy_1;
  1317. save_it->centre_guy_2=centre_guy_2;
  1318. save_it->in_range=in_range;
  1319. save_it->in_header_rng=in_header_rng;
  1320. save_it->in_shot_rng=in_shot_rng;
  1321. save_it->taker_x=taker_x;
  1322. save_it->taker_y=taker_y;
  1323. save_it->penalty_shot=penalty_shot;
  1324. save_it->penalties=penalties;
  1325. save_it->penalty_game=penalty_game;
  1326. save_it->home_pens_left=home_pens_left;
  1327. save_it->away_pens_left=away_pens_left;
  1328. save_it->penalty_counter=penalty_counter;
  1329. save_it->pen_taker_a=pen_taker_a;
  1330. save_it->pen_taker_b=pen_taker_b;
  1331. save_it->penalty_team=penalty_team;
  1332. save_it->penalty_taker=penalty_taker;
  1333. save_it->penalty_taker_a=penalty_taker_a;
  1334. save_it->penalty_taker_b=penalty_taker_b;
  1335. save_it->setp_taker=setp_taker;
  1336. save_it->fkick_taker=fkick_taker;
  1337. save_it->fkick_taker_a=fkick_taker_a;
  1338. save_it->fkick_taker_b=fkick_taker_b;
  1339. save_it->gkick_taker=gkick_taker;
  1340. save_it->goal_kicker_a=goal_kicker_a;
  1341. save_it->goal_kicker_b=goal_kicker_b;
  1342. save_it->corner_taker=corner_taker;
  1343. save_it->corn_kicker_a=corn_kicker_a;
  1344. save_it->corn_kicker_b=corn_kicker_b;
  1345. save_it->ktaker=ktaker;
  1346. save_it->bad_guy=bad_guy;
  1347. save_it->direct_fk=direct_fk;
  1348. save_it->play_advantage=play_advantage;
  1349. save_it->set_piece_on=set_piece_on;
  1350. save_it->throw_in_taker=throw_in_taker;
  1351. save_it->main_man=main_man;
  1352. save_it->player_num=player_num;
  1353. save_it->savex=savex;
  1354. save_it->savey=savey;
  1355. save_it->savez=savez;
  1356. save_it->shot_acknowledged=shot_acknowledged;
  1357. save_it->shot_pending=shot_pending;
  1358. save_it->real_shot=real_shot;
  1359. save_it->shot_missed=shot_missed;
  1360. save_it->shot_saved=shot_saved;
  1361. save_it->drib_opps=drib_opps;
  1362. save_it->stop_and_face=stop_and_face;
  1363. save_it->x_face=x_face;
  1364. save_it->y_face=y_face;
  1365. save_it->offside_now=offside_now;
  1366. save_it->can_be_offside=can_be_offside;
  1367. save_it->ref_accuracy=ref_accuracy;
  1368. save_it->ref_strictness=ref_strictness;
  1369. save_it->ref_wait=ref_wait;
  1370. save_it->tussle_ptr=tussle_ptr;
  1371. save_it->crowd_a=crowd_a;
  1372. save_it->crowd_b=crowd_b;
  1373. save_it->kickoff=kickoff;
  1374. save_it->end_game=end_game;
  1375. save_it->team_a=team_a;
  1376. save_it->team_b=team_b;
  1377. save_it->last_centre=last_centre;
  1378. save_it->need_result=need_result;
  1379. save_it->injury_time=injury_time;
  1380. save_it->special_move=special_move;
  1381. save_it->match_half=match_half;
  1382. save_it->opt_user=opt_user;
  1383. save_it->opt_team=opt_team;
  1384. save_it->options_on=options_on;
  1385. save_it->line_up=line_up;
  1386. save_it->player_being_subbed=player_being_subbed;
  1387. save_it->player_on_off=player_on_off;
  1388. save_it->player_coming_on=player_coming_on;
  1389. save_it->booking=booking;
  1390. save_it->subbing_now=subbing_now;
  1391. save_it->first_update=first_update;
  1392. save_it->newdx=newdx;
  1393. save_it->newdy=newdy;
  1394. save_it->wind_on=wind_on;
  1395. save_it->wind_d_trend=wind_d_trend;
  1396. save_it->wind_s_trend=wind_s_trend;
  1397. save_it->wind_x=wind_x;
  1398. save_it->wind_y=wind_y;
  1399. save_it->wind_speed=wind_speed;
  1400. save_it->init_wind_x=init_wind_x;
  1401. save_it->init_wind_y=init_wind_y;
  1402. save_it->init_wind_speed=init_wind_speed;
  1403. save_it->wind_var_ang=wind_var_ang;
  1404. save_it->tactics_a=tactics_a;
  1405. save_it->tactics_b=tactics_b;
  1406. save_it->old_tac_a=old_tac_a;
  1407. save_it->old_tac_b=old_tac_b;
  1408. save_it->afr1=afr1;
  1409. save_it->afr2=afr2;
  1410. save_it->man2man_a=man2man_a;
  1411. save_it->man2man_b=man2man_b;
  1412. save_it->next_mins=next_mins;
  1413. save_it->time_factor=time_factor;
  1414. save_it->clock_running=clock_running;
  1415. save_it->demo_match=demo_match;
  1416. save_it->rolling_clock=rolling_clock;
  1417. save_it->arrow_guy=arrow_guy;
  1418. save_it->rand_seed=rand_seed;
  1419. save_it->seed=seed;
  1420. save_it->man_down=man_down;
  1421. save_it->launch_type=launch_type;
  1422. save_it->launch_x=launch_x;
  1423. save_it->launch_y=launch_y;
  1424. save_it->ballxdis=ballxdis;
  1425. save_it->ballydis=ballydis;
  1426. save_it->ballzdis=ballzdis;
  1427. save_it->ballx=ballx;
  1428. save_it->bally=bally;
  1429. save_it->ballz=ballz;
  1430. save_it->ballx_out=ballx_out;
  1431. save_it->bally_out=bally_out;
  1432. save_it->ballz_out=ballz_out;
  1433. save_it->b_xoff=b_xoff;
  1434. save_it->b_yoff=b_yoff;
  1435. save_it->b_zoff=b_zoff;
  1436. save_it->save_ballx=save_ballx;
  1437. save_it->save_bally=save_bally;
  1438. save_it->save_ballz=save_ballz;
  1439. save_it->save_ball_poss=save_ball_poss;
  1440. save_it->good_poss=good_poss;
  1441. save_it->eff_ballx=eff_ballx;
  1442. save_it->eff_bally=eff_bally;
  1443. save_it->eff_ballz=eff_ballz;
  1444. save_it->prev_ballx=prev_ballx;
  1445. save_it->prev_bally=prev_bally;
  1446. save_it->prev_ballz=prev_ballz;
  1447. save_it->ns_ballx=ns_ballx;
  1448. save_it->ns_bally=ns_bally;
  1449. save_it->ns_ballz=ns_ballz;
  1450. save_it->ball_zspin=ball_zspin;
  1451. save_it->ball_xyspin=ball_xyspin;
  1452. save_it->full_zspin=full_zspin;
  1453. save_it->full_xyspin=full_xyspin;
  1454. save_it->shoot_x=shoot_x;
  1455. save_it->shoot_y=shoot_y;
  1456. save_it->nearest_a=nearest_a;
  1457. save_it->nearest_b=nearest_b;
  1458. save_it->old_ltouch=old_ltouch;
  1459. save_it->old_ball_poss=old_ball_poss;
  1460. save_it->use_ball_limit=use_ball_limit;
  1461. save_it->near_path_a=near_path_a;
  1462. save_it->near_path_b=near_path_b;
  1463. save_it->zone1_x=zone1_x;
  1464. save_it->zone1_y=zone1_y;
  1465. save_it->zone2_x=zone2_x;
  1466. save_it->zone2_y=zone2_y;
  1467. save_it->incident_x=incident_x;
  1468. save_it->incident_y=incident_y;
  1469. save_it->difficulty=difficulty;
  1470. save_it->match_mode=match_mode;
  1471. save_it->dead_ball_cnt=dead_ball_cnt;
  1472. save_it->defense_a=defense_a;
  1473. save_it->defense_b=defense_b;
  1474. save_it->poss_mode=poss_mode;
  1475. save_it->ball_travel=ball_travel;
  1476. save_it->select_cnt=select_cnt;
  1477. save_it->already_there=already_there;
  1478. save_it->reselection=reselection;
  1479. save_it->offside_on=offside_on;
  1480. // "C" Vars...
  1481. save_it->joy1_max_x=joy1_max_x;
  1482. save_it->joy1_min_x=joy1_min_x;
  1483. save_it->joy1_max_y=joy1_max_y;
  1484. save_it->joy1_min_y=joy1_min_y;
  1485. save_it->joy1_cnt_x=joy1_cnt_x;
  1486. save_it->joy1_cnt_y=joy1_cnt_y;
  1487. save_it->joy2_max_x=joy2_max_x;
  1488. save_it->joy2_min_x=joy2_min_x;
  1489. save_it->joy2_max_y=joy2_max_y;
  1490. save_it->joy2_min_y=joy2_min_y;
  1491. save_it->joy2_cnt_x=joy2_cnt_x;
  1492. save_it->joy2_cnt_y=joy2_cnt_y;
  1493. }
  1494. /******************************************************************************
  1495. ******************************************************************************/
  1496. void restore_state(save_data *save_it)
  1497. {
  1498. memcpy(teams,save_it->teams,sizeof(teams));
  1499. memcpy(&match_time,&save_it->match_time,sizeof(match_time));
  1500. memcpy(refs,save_it->refs,sizeof(refs));
  1501. memcpy(speech_tab,save_it->speech_tab,sizeof(speech_tab));
  1502. memcpy(wguys,save_it->wguys,sizeof(wguys));
  1503. memcpy(sel_circle,save_it->sel_circle,sizeof(sel_circle));
  1504. memcpy(burst_timer,save_it->burst_timer,sizeof(burst_timer));
  1505. memcpy(auto_users_list_a,save_it->auto_users_list_a,sizeof(auto_users_list_a));
  1506. memcpy(auto_users_list_b,save_it->auto_users_list_b,sizeof(auto_users_list_b));
  1507. memcpy(rand1_tab,save_it->rand1_tab,sizeof(rand1_tab));
  1508. memcpy(rand2_tab,save_it->rand2_tab,sizeof(rand2_tab));
  1509. memcpy(man2man,save_it->man2man,sizeof(man2man));
  1510. memcpy(glob_str1,save_it->glob_str1,sizeof(glob_str1));
  1511. memcpy(glob_str2,save_it->glob_str2,sizeof(glob_str2));
  1512. sub_pending=save_it->sub_pending;
  1513. return_12=save_it->return_12;
  1514. shamed_player=save_it->shamed_player;
  1515. old_min=save_it->old_min;
  1516. users_left=save_it->users_left;
  1517. setp_x=save_it->setp_x;
  1518. setp_y=save_it->setp_y;
  1519. setp_wait_cnt=save_it->setp_wait_cnt;
  1520. frame=save_it->frame;
  1521. kick_off=save_it->kick_off;
  1522. keep_timer=save_it->keep_timer;
  1523. stop_clock=save_it->stop_clock;
  1524. keep_dive=save_it->keep_dive;
  1525. hold_up_play=save_it->hold_up_play;
  1526. wall_is_up=save_it->wall_is_up;
  1527. card_is_out=save_it->card_is_out;
  1528. crowd_mood_a=save_it->crowd_mood_a;
  1529. crowd_mood_b=save_it->crowd_mood_b;
  1530. possession=save_it->possession;
  1531. poss_held=save_it->poss_held;
  1532. arrow_on=save_it->arrow_on;
  1533. logic_cnt=save_it->logic_cnt;
  1534. ball_move=save_it->ball_move;
  1535. first_bounce=save_it->first_bounce;
  1536. swerve=save_it->swerve;
  1537. spin_cnt=save_it->spin_cnt;
  1538. spin_ball=save_it->spin_ball;
  1539. prediction=save_it->prediction;
  1540. set_xyspin=save_it->set_xyspin;
  1541. set_zspin=save_it->set_zspin;
  1542. ball_horz_ang=save_it->ball_horz_ang;
  1543. ball_vert_ang=save_it->ball_vert_ang;
  1544. max_sw_factor=save_it->max_sw_factor;
  1545. swerve_factor=save_it->swerve_factor;
  1546. rebound_ball=save_it->rebound_ball;
  1547. headed_ball=save_it->headed_ball;
  1548. say_names=save_it->say_names;
  1549. fired_a_shot=save_it->fired_a_shot;
  1550. comm_pass=save_it->comm_pass;
  1551. comm_pass_type=save_it->comm_pass_type;
  1552. keeper_spd=save_it->keeper_spd;
  1553. keeper_down=save_it->keeper_down;
  1554. save_direction=save_it->save_direction;
  1555. keeper_will_save=save_it->keeper_will_save;
  1556. keeper_on_grnd=save_it->keeper_on_grnd;
  1557. keeper_contact=save_it->keeper_contact;
  1558. ball_in_goal=save_it->ball_in_goal;
  1559. ball_in_hands=save_it->ball_in_hands;
  1560. game_action=save_it->game_action;
  1561. throw_cnt=save_it->throw_cnt;
  1562. team_a_goals=save_it->team_a_goals;
  1563. team_b_goals=save_it->team_b_goals;
  1564. last_goal=save_it->last_goal;
  1565. scorer_running=save_it->scorer_running;
  1566. just_scored=save_it->just_scored;
  1567. just_thrown=save_it->just_thrown;
  1568. goal_scorer=save_it->goal_scorer;
  1569. pass_type=save_it->pass_type;
  1570. kick_type=save_it->kick_type;
  1571. receiver=save_it->receiver;
  1572. cross_now=save_it->cross_now;
  1573. auto_select=save_it->auto_select;
  1574. must_face=save_it->must_face;
  1575. must_face_time=save_it->must_face_time;
  1576. must_face_x=save_it->must_face_x;
  1577. must_face_y=save_it->must_face_y;
  1578. must_shoot=save_it->must_shoot;
  1579. chip_pass=save_it->chip_pass;
  1580. must_pass=save_it->must_pass;
  1581. must_punt=save_it->must_punt;
  1582. keeper_a_in_box=save_it->keeper_a_in_box;
  1583. keeper_b_in_box=save_it->keeper_b_in_box;
  1584. keeper_steps=save_it->keeper_steps;
  1585. save_block=save_it->save_block;
  1586. save_xoff=save_it->save_xoff;
  1587. save_yoff=save_it->save_yoff;
  1588. save_zoff=save_it->save_zoff;
  1589. shot_speed=save_it->shot_speed;
  1590. scr_x=save_it->scr_x;
  1591. scr_y=save_it->scr_y;
  1592. ball_speed=save_it->ball_speed;
  1593. ball_int_speed=save_it->ball_int_speed;
  1594. interceptor_a=save_it->interceptor_a;
  1595. interceptor_b=save_it->interceptor_b;
  1596. in_cross_area=save_it->in_cross_area;
  1597. close_in_number=save_it->close_in_number;
  1598. shooter=save_it->shooter;
  1599. ball_inair=save_it->ball_inair;
  1600. super_shot=save_it->super_shot;
  1601. opponents_near_holder=save_it->opponents_near_holder;
  1602. opponents_really_close=save_it->opponents_really_close;
  1603. ball_poss=save_it->ball_poss;
  1604. sender_1_2=save_it->sender_1_2;
  1605. ball_still=save_it->ball_still;
  1606. last_touch=save_it->last_touch;
  1607. want_pass=save_it->want_pass;
  1608. before=save_it->before;
  1609. support_me=save_it->support_me;
  1610. pre_kp_touch=save_it->pre_kp_touch;
  1611. prev_touch=save_it->prev_touch;
  1612. ball_limbo_p=save_it->ball_limbo_p;
  1613. ball_limbo_on=save_it->ball_limbo_on;
  1614. ball_limbo_c=save_it->ball_limbo_c;
  1615. ball_released=save_it->ball_released;
  1616. cannot_pick_up=save_it->cannot_pick_up;
  1617. forced=save_it->forced;
  1618. last_user_a=save_it->last_user_a;
  1619. last_user_b=save_it->last_user_b;
  1620. last_plr_a=save_it->last_plr_a;
  1621. last_plr_b=save_it->last_plr_b;
  1622. players_off_a=save_it->players_off_a;
  1623. players_off_b=save_it->players_off_b;
  1624. want_pass_stat=save_it->want_pass_stat;
  1625. ball_zone1=save_it->ball_zone1;
  1626. ball_zone2=save_it->ball_zone2;
  1627. ball_out_of_play=save_it->ball_out_of_play;
  1628. receiver_a=save_it->receiver_a;
  1629. receiver_b=save_it->receiver_b;
  1630. ready_centre=save_it->ready_centre;
  1631. shot_attempt=save_it->shot_attempt;
  1632. force_select=save_it->force_select;
  1633. heading_ball=save_it->heading_ball;
  1634. flag=save_it->flag;
  1635. rep_camera=save_it->rep_camera;
  1636. sub_camera=save_it->sub_camera;
  1637. allow_replay=save_it->allow_replay;
  1638. replay_pos=save_it->replay_pos;
  1639. old_rep_pos=save_it->old_rep_pos;
  1640. replay_cnt=save_it->replay_cnt;
  1641. pitch_sprs=save_it->pitch_sprs;
  1642. lp_user=save_it->lp_user;
  1643. fixed_net_user=save_it->fixed_net_user;
  1644. auto_users_a=save_it->auto_users_a;
  1645. auto_users_b=save_it->auto_users_b;
  1646. play_ball_a=save_it->play_ball_a;
  1647. play_ball_b=save_it->play_ball_b;
  1648. new_select=save_it->new_select;
  1649. auto_intercept=save_it->auto_intercept;
  1650. closest=save_it->closest;
  1651. f1_down=save_it->f1_down;
  1652. f2_down=save_it->f2_down;
  1653. spec_kick_type=save_it->spec_kick_type;
  1654. setp_hgt=save_it->setp_hgt;
  1655. setp_power=save_it->setp_power;
  1656. setp_kick_x=save_it->setp_kick_x;
  1657. setp_kick_y=save_it->setp_kick_y;
  1658. setp_bxd=save_it->setp_bxd;
  1659. setp_byd=save_it->setp_byd;
  1660. setp_bzd=save_it->setp_bzd;
  1661. user_taker=save_it->user_taker;
  1662. user_taker2=save_it->user_taker2;
  1663. user_controlled=save_it->user_controlled;
  1664. user_plr=save_it->user_plr;
  1665. after_touch_on=save_it->after_touch_on;
  1666. drive_shot=save_it->drive_shot;
  1667. newk_shot=save_it->newk_shot;
  1668. wallx=save_it->wallx;
  1669. wally=save_it->wally;
  1670. men_in_wall=save_it->men_in_wall;
  1671. keeper_pos_x=save_it->keeper_pos_x;
  1672. keeper_pos_y=save_it->keeper_pos_y;
  1673. centre_guy_1=save_it->centre_guy_1;
  1674. centre_guy_2=save_it->centre_guy_2;
  1675. in_range=save_it->in_range;
  1676. in_header_rng=save_it->in_header_rng;
  1677. in_shot_rng=save_it->in_shot_rng;
  1678. taker_x=save_it->taker_x;
  1679. taker_y=save_it->taker_y;
  1680. penalty_shot=save_it->penalty_shot;
  1681. penalties=save_it->penalties;
  1682. penalty_game=save_it->penalty_game;
  1683. home_pens_left=save_it->home_pens_left;
  1684. away_pens_left=save_it->away_pens_left;
  1685. penalty_counter=save_it->penalty_counter;
  1686. pen_taker_a=save_it->pen_taker_a;
  1687. pen_taker_b=save_it->pen_taker_b;
  1688. penalty_team=save_it->penalty_team;
  1689. penalty_taker=save_it->penalty_taker;
  1690. penalty_taker_a=save_it->penalty_taker_a;
  1691. penalty_taker_b=save_it->penalty_taker_b;
  1692. setp_taker=save_it->setp_taker;
  1693. fkick_taker=save_it->fkick_taker;
  1694. fkick_taker_a=save_it->fkick_taker_a;
  1695. fkick_taker_b=save_it->fkick_taker_b;
  1696. gkick_taker=save_it->gkick_taker;
  1697. goal_kicker_a=save_it->goal_kicker_a;
  1698. goal_kicker_b=save_it->goal_kicker_b;
  1699. corner_taker=save_it->corner_taker;
  1700. corn_kicker_a=save_it->corn_kicker_a;
  1701. corn_kicker_b=save_it->corn_kicker_b;
  1702. ktaker=save_it->ktaker;
  1703. bad_guy=save_it->bad_guy;
  1704. direct_fk=save_it->direct_fk;
  1705. play_advantage=save_it->play_advantage;
  1706. set_piece_on=save_it->set_piece_on;
  1707. throw_in_taker=save_it->throw_in_taker;
  1708. main_man=save_it->main_man;
  1709. player_num=save_it->player_num;
  1710. savex=save_it->savex;
  1711. savey=save_it->savey;
  1712. savez=save_it->savez;
  1713. shot_acknowledged=save_it->shot_acknowledged;
  1714. shot_pending=save_it->shot_pending;
  1715. real_shot=save_it->real_shot;
  1716. shot_missed=save_it->shot_missed;
  1717. shot_saved=save_it->shot_saved;
  1718. drib_opps=save_it->drib_opps;
  1719. stop_and_face=save_it->stop_and_face;
  1720. x_face=save_it->x_face;
  1721. y_face=save_it->y_face;
  1722. offside_now=save_it->offside_now;
  1723. can_be_offside=save_it->can_be_offside;
  1724. ref_accuracy=save_it->ref_accuracy;
  1725. ref_strictness=save_it->ref_strictness;
  1726. ref_wait=save_it->ref_wait;
  1727. tussle_ptr=save_it->tussle_ptr;
  1728. crowd_a=save_it->crowd_a;
  1729. crowd_b=save_it->crowd_b;
  1730. kickoff=save_it->kickoff;
  1731. end_game=save_it->end_game;
  1732. team_a=save_it->team_a;
  1733. team_b=save_it->team_b;
  1734. last_centre=save_it->last_centre;
  1735. need_result=save_it->need_result;
  1736. injury_time=save_it->injury_time;
  1737. special_move=save_it->special_move;
  1738. match_half=save_it->match_half;
  1739. opt_user=save_it->opt_user;
  1740. opt_team=save_it->opt_team;
  1741. options_on=save_it->options_on;
  1742. line_up=save_it->line_up;
  1743. player_being_subbed=save_it->player_being_subbed;
  1744. player_on_off=save_it->player_on_off;
  1745. player_coming_on=save_it->player_coming_on;
  1746. booking=save_it->booking;
  1747. subbing_now=save_it->subbing_now;
  1748. first_update=save_it->first_update;
  1749. newdx=save_it->newdx;
  1750. newdy=save_it->newdy;
  1751. wind_on=save_it->wind_on;
  1752. wind_d_trend=save_it->wind_d_trend;
  1753. wind_s_trend=save_it->wind_s_trend;
  1754. wind_x=save_it->wind_x;
  1755. wind_y=save_it->wind_y;
  1756. wind_speed=save_it->wind_speed;
  1757. init_wind_x=save_it->init_wind_x;
  1758. init_wind_y=save_it->init_wind_y;
  1759. init_wind_speed=save_it->init_wind_speed;
  1760. wind_var_ang=save_it->wind_var_ang;
  1761. tactics_a=save_it->tactics_a;
  1762. tactics_b=save_it->tactics_b;
  1763. old_tac_a=save_it->old_tac_a;
  1764. old_tac_b=save_it->old_tac_b;
  1765. afr1=save_it->afr1;
  1766. afr2=save_it->afr2;
  1767. man2man_a=save_it->man2man_a;
  1768. man2man_b=save_it->man2man_b;
  1769. next_mins=save_it->next_mins;
  1770. time_factor=save_it->time_factor;
  1771. clock_running=save_it->clock_running;
  1772. demo_match=save_it->demo_match;
  1773. rolling_clock=save_it->rolling_clock;
  1774. arrow_guy=save_it->arrow_guy;
  1775. rand_seed=save_it->rand_seed;
  1776. seed=save_it->seed;
  1777. man_down=save_it->man_down;
  1778. launch_type=save_it->launch_type;
  1779. launch_x=save_it->launch_x;
  1780. launch_y=save_it->launch_y;
  1781. ballxdis=save_it->ballxdis;
  1782. ballydis=save_it->ballydis;
  1783. ballzdis=save_it->ballzdis;
  1784. ballx=save_it->ballx;
  1785. bally=save_it->bally;
  1786. ballz=save_it->ballz;
  1787. ballx_out=save_it->ballx_out;
  1788. bally_out=save_it->bally_out;
  1789. ballz_out=save_it->ballz_out;
  1790. b_xoff=save_it->b_xoff;
  1791. b_yoff=save_it->b_yoff;
  1792. b_zoff=save_it->b_zoff;
  1793. save_ballx=save_it->save_ballx;
  1794. save_bally=save_it->save_bally;
  1795. save_ballz=save_it->save_ballz;
  1796. save_ball_poss=save_it->save_ball_poss;
  1797. good_poss=save_it->good_poss;
  1798. eff_ballx=save_it->eff_ballx;
  1799. eff_bally=save_it->eff_bally;
  1800. eff_ballz=save_it->eff_ballz;
  1801. prev_ballx=save_it->prev_ballx;
  1802. prev_bally=save_it->prev_bally;
  1803. prev_ballz=save_it->prev_ballz;
  1804. ns_ballx=save_it->ns_ballx;
  1805. ns_bally=save_it->ns_bally;
  1806. ns_ballz=save_it->ns_ballz;
  1807. ball_zspin=save_it->ball_zspin;
  1808. ball_xyspin=save_it->ball_xyspin;
  1809. full_zspin=save_it->full_zspin;
  1810. full_xyspin=save_it->full_xyspin;
  1811. shoot_x=save_it->shoot_x;
  1812. shoot_y=save_it->shoot_y;
  1813. nearest_a=save_it->nearest_a;
  1814. nearest_b=save_it->nearest_b;
  1815. old_ltouch=save_it->old_ltouch;
  1816. old_ball_poss=save_it->old_ball_poss;
  1817. use_ball_limit=save_it->use_ball_limit;
  1818. near_path_a=save_it->near_path_a;
  1819. near_path_b=save_it->near_path_b;
  1820. zone1_x=save_it->zone1_x;
  1821. zone1_y=save_it->zone1_y;
  1822. zone2_x=save_it->zone2_x;
  1823. zone2_y=save_it->zone2_y;
  1824. incident_x=save_it->incident_x;
  1825. incident_y=save_it->incident_y;
  1826. difficulty=save_it->difficulty;
  1827. match_mode=save_it->match_mode;
  1828. dead_ball_cnt=save_it->dead_ball_cnt;
  1829. defense_a=save_it->defense_a;
  1830. defense_b=save_it->defense_b;
  1831. poss_mode=save_it->poss_mode;
  1832. ball_travel=save_it->ball_travel;
  1833. select_cnt=save_it->select_cnt;
  1834. already_there=save_it->already_there;
  1835. reselection=save_it->reselection;
  1836. offside_on=save_it->offside_on;
  1837. // "C" Vars...
  1838. joy1_max_x=save_it->joy1_max_x;
  1839. joy1_min_x=save_it->joy1_min_x;
  1840. joy1_max_y=save_it->joy1_max_y;
  1841. joy1_min_y=save_it->joy1_min_y;
  1842. joy1_cnt_x=save_it->joy1_cnt_x;
  1843. joy1_cnt_y=save_it->joy1_cnt_y;
  1844. joy2_max_x=save_it->joy2_max_x;
  1845. joy2_min_x=save_it->joy2_min_x;
  1846. joy2_max_y=save_it->joy2_max_y;
  1847. joy2_min_y=save_it->joy2_min_y;
  1848. joy2_cnt_x=save_it->joy2_cnt_x;
  1849. joy2_cnt_y=save_it->joy2_cnt_y;
  1850. }
  1851. #ifdef EURO96
  1852. /******************************************************************************
  1853. *****************************************************************************/
  1854. void checksum_state()
  1855. {
  1856. short *ptr=(short *)state_ptr;
  1857. ptr+=(sizeof(save_data)/sizeof(short));
  1858. short lim=CHECKSUM_CHUNK;
  1859. _disable();
  1860. // Must finish checksum before netsend...
  1861. if (checksum_ptr<ptr)
  1862. {
  1863. // Some data left to checksum...
  1864. for (short i=0; i<lim; i++)
  1865. {
  1866. state_checksum^=*checksum_ptr++;
  1867. if (checksum_ptr>=ptr)
  1868. i=lim;
  1869. }
  1870. }
  1871. logic_cnt++;
  1872. _enable();
  1873. }
  1874. /******************************************************************************
  1875. ******************************************************************************/
  1876. void process_state()
  1877. {
  1878. checksum_state();
  1879. if (!(logic_cnt%(REAL_SPEED*STATE_INTERVAL)))
  1880. {
  1881. // Time for a save...
  1882. if (state_ptr==&state1)
  1883. state_ptr=&state2;
  1884. else
  1885. state_ptr=&state1;
  1886. save_state(state_ptr);
  1887. checksum_ptr=(short *)state_ptr;
  1888. }
  1889. }
  1890. /******************************************************************************
  1891. ******************************************************************************/
  1892. void reset_state(char buff)
  1893. {
  1894. // Buff indicates current (0) or previous state (1)!
  1895. if (buff)
  1896. // Swap state_ptr...
  1897. if (state_ptr==&state1)
  1898. state_ptr=&state2;
  1899. else
  1900. state_ptr=&state1;
  1901. restore_state(state_ptr);
  1902. checksum_ptr=(short *)state_ptr;
  1903. state_checksum=0xafaf;
  1904. }
  1905. #endif
  1906. /******************************************************************************
  1907. *****************************************************************************/
  1908. void variable_wind()
  1909. {
  1910. // Variable speed and direction around initial settings...
  1911. // Do dir.
  1912. if (wind_d_trend>0)
  1913. {
  1914. // Wind current dir gets further from initial setting...
  1915. wind_d_trend--;
  1916. if (wind_var_ang<0)
  1917. wind_var_ang-=(MAX_WIND_CHANGE*seed/128);
  1918. else
  1919. wind_var_ang+=(MAX_WIND_CHANGE*seed/128);
  1920. wind_x=(init_wind_x*cos(wind_var_ang))-(init_wind_y*sin(wind_var_ang));
  1921. wind_y=(init_wind_y*cos(wind_var_ang))+(init_wind_x*sin(wind_var_ang));
  1922. }
  1923. else
  1924. {
  1925. if (wind_d_trend<0)
  1926. {
  1927. // Wind current dir returns to initial setting...
  1928. wind_d_trend++;
  1929. if (wind_var_ang<0)
  1930. wind_var_ang+=(MAX_WIND_CHANGE*seed/128);
  1931. else
  1932. wind_var_ang-=(MAX_WIND_CHANGE*seed/128);
  1933. wind_x=(init_wind_x*cos(wind_var_ang))-(init_wind_y*sin(wind_var_ang));
  1934. wind_y=(init_wind_y*cos(wind_var_ang))+(init_wind_x*sin(wind_var_ang));
  1935. }
  1936. else
  1937. {
  1938. // New trend...
  1939. if (ABS(wind_var_ang*128/PI)<seed)
  1940. wind_d_trend=WIND_BLUSTERINESS;
  1941. else
  1942. wind_d_trend=-WIND_BLUSTERINESS;
  1943. }
  1944. }
  1945. af_randomize();
  1946. // Do speed.
  1947. if (wind_s_trend>0)
  1948. {
  1949. // Increment difference in speed...
  1950. wind_s_trend--;
  1951. if ((wind_speed-init_wind_speed)<0)
  1952. {
  1953. wind_speed-=(MAX_WIND_S_CHANGE*seed/128);
  1954. if (wind_speed<0)
  1955. wind_speed=0;
  1956. }
  1957. else
  1958. {
  1959. wind_speed+=(MAX_WIND_S_CHANGE*seed/128);
  1960. if (wind_speed>128)
  1961. wind_speed=128;
  1962. }
  1963. }
  1964. else
  1965. {
  1966. if (wind_s_trend<0)
  1967. {
  1968. // Decrement difference in speed...
  1969. wind_s_trend++;
  1970. if ((wind_speed-init_wind_speed)<0)
  1971. {
  1972. wind_speed+=(MAX_WIND_S_CHANGE*seed/128);
  1973. if (wind_speed>128)
  1974. wind_speed=128;
  1975. }
  1976. else
  1977. {
  1978. wind_speed-=(MAX_WIND_S_CHANGE*seed/128);
  1979. if (wind_speed<0)
  1980. wind_speed=0;
  1981. }
  1982. }
  1983. else
  1984. {
  1985. // New trend...
  1986. if (ABS(wind_speed-init_wind_speed)<(seed/2))
  1987. wind_s_trend=WIND_GUSTINESS;
  1988. else
  1989. wind_s_trend=-WIND_GUSTINESS;
  1990. }
  1991. }
  1992. }
  1993. /******************************************************************************
  1994. ******************************************************************************/
  1995. int coo=0;
  1996. char gkey=0;
  1997. void do_logic()
  1998. {
  1999. init_pitch_sprites();
  2000. #ifdef SAVE_GAME
  2001. if (keys[0x11]) // w
  2002. {
  2003. save_game();
  2004. }
  2005. if (keys[0x2c]) // z
  2006. {
  2007. restore_game();
  2008. }
  2009. #endif
  2010. #ifndef COVERDISK
  2011. if (debug && key_togs[0x30]) // b
  2012. {
  2013. // Move ball around with mouse.
  2014. ReportMouse();
  2015. ballx=Mouse.x*5-160;
  2016. bally=Mouse.y*5-160;
  2017. char key=0;
  2018. float x,y;
  2019. }
  2020. #endif
  2021. // Normal logic mode.
  2022. /*
  2023. if (!match_mode)
  2024. {
  2025. if (!--pen_cnt)
  2026. force_penalty();
  2027. }
  2028. */
  2029. frame=(frame) ? 0:1;
  2030. af_randomize();
  2031. if (!on_3d)
  2032. {
  2033. ReportMouse();
  2034. }
  2035. process_subs();
  2036. if (wind_on<0)
  2037. variable_wind(); // Get current wind parameters...
  2038. process_ball();
  2039. match_rules();
  2040. keeper_boxes();
  2041. player_distances();
  2042. get_nearest(); // near_path_a, near_path_b
  2043. get_opp_near_ball(ball_poss);
  2044. process_speech();
  2045. process_comments();
  2046. process_flags();
  2047. process_teams();
  2048. new_users();
  2049. select_all_hlites();
  2050. process_offs();
  2051. if (!match_mode && comsetp)
  2052. --comsetp;
  2053. }
  2054. /******************************************************************************
  2055. *****************************************************************************/
  2056. void stop_mf_time()
  2057. {
  2058. /*
  2059. int cl=clock();
  2060. int c=cl/CLOCKS_PER_SEC;
  2061. last_second=c;
  2062. old_clock=cl;
  2063. */
  2064. oldcnt=count-1;
  2065. }
  2066. /******************************************************************************
  2067. *****************************************************************************/
  2068. void pause_game()
  2069. {
  2070. char key=0;
  2071. do{
  2072. }while (paused);
  2073. stop_mf_time();
  2074. }
  2075. /******************************************************************************
  2076. *****************************************************************************/
  2077. extern "C" char calibrated_1,calibrated_2;
  2078. /******************************************************************************
  2079. *****************************************************************************/
  2080. void init_joy1()
  2081. {
  2082. calibrated_1=FALSE;
  2083. joy1_min_x=20000;
  2084. joy1_max_x=0;
  2085. joy1_min_y=20000;
  2086. joy1_max_y=0;
  2087. }
  2088. /******************************************************************************
  2089. *****************************************************************************/
  2090. void init_joy2()
  2091. {
  2092. calibrated_2=FALSE;
  2093. joy2_min_x=20000;
  2094. joy2_max_x=0;
  2095. joy2_min_y=20000;
  2096. joy2_max_y=0;
  2097. }
  2098. /******************************************************************************
  2099. *****************************************************************************/
  2100. void init_joys()
  2101. {
  2102. init_joy1();
  2103. init_joy2();
  2104. }
  2105. void process_keys()
  2106. {
  2107. if (!demo_match || debug)
  2108. {
  2109. while(escape_pending>0)
  2110. {
  2111. if (keys[0x15]) // Y
  2112. {
  2113. add_message("Leaving Match!",RED,TRUE);
  2114. escape_pending=-1;
  2115. }
  2116. if (keys[0x31]) // N
  2117. {
  2118. add_message(" ",WHITE,TRUE);
  2119. escape_pending=FALSE;
  2120. stop_mf_time();
  2121. }
  2122. }
  2123. if (paused)
  2124. pause_game();
  2125. if (keys[0x3b] && keys[0x1d] && joystick1_on)
  2126. {
  2127. // Ctrl F1...
  2128. calibrated_1=FALSE;
  2129. init_joy1();
  2130. add_message("Auto Calibrating Port 1",WHITE,TRUE);
  2131. }
  2132. if (keys[0x3c] && keys[0x1d] && joystick2_on)
  2133. {
  2134. // Ctrl F2...
  2135. calibrated_2=FALSE;
  2136. init_joy2();
  2137. add_message("Auto Calibrating Port 2",WHITE,TRUE);
  2138. }
  2139. #ifdef NO_AUTO_SEL
  2140. if (keys[0x43]) // f9
  2141. if (key_togs[0x43])
  2142. add_message("Manual Switching",WHITE,TRUE);
  2143. else
  2144. add_message("Automatic Switching",WHITE,TRUE);
  2145. #endif
  2146. #ifndef COVERDISK
  2147. if (debug)
  2148. {
  2149. if (keys[0x11] && ball_poss && !match_mode)
  2150. {
  2151. short b=ball_poss;
  2152. holder_lose_ball();
  2153. init_foul((b<12 ? 13:2),TRUE,TRUE); // pass no. of fouler.
  2154. }
  2155. if (keys[0x0f])
  2156. delete_net_user(2);
  2157. /*
  2158. if (keys[0x14]) // t
  2159. if (key_togs[0x14])
  2160. tweening=TRUE;
  2161. else
  2162. tweening=FALSE;
  2163. */
  2164. if (keys[0x14]) // t
  2165. {
  2166. do; while(keys[0x14]);
  2167. if (++xinfo>8)
  2168. xinfo=0;
  2169. }
  2170. /*
  2171. if (keys[0x0f]) // TAB
  2172. {
  2173. delete_net_user(2);
  2174. while(keys[0x14]);
  2175. }
  2176. */
  2177. if (keys[0x21]) // f
  2178. {
  2179. // Fixed speed...
  2180. mf_fixed=TRUE;
  2181. mf_scale=1;
  2182. }
  2183. if (keys[0x22]) // g
  2184. {
  2185. // Variable speed...
  2186. mf_fixed=FALSE;
  2187. }
  2188. if (keys[0x4a]) // +
  2189. {
  2190. // Game Faster...
  2191. if (game_speed>0)
  2192. game_speed--;
  2193. }
  2194. if (keys[0x4e]) // -
  2195. {
  2196. // Game Slower...
  2197. game_speed++;
  2198. }
  2199. }
  2200. #endif
  2201. if (!network_on && !player_on_off && !line_up && match_mode!=SWAP_ENDS)
  2202. {
  2203. #ifdef SUPPORT_LP
  2204. if (keys[0x3b] || (users_dir[0].f&8 && users_dir[0].f&4 && !(users_dir[0].f&48))) // LS + RS
  2205. {
  2206. if (num_of_users>=1)
  2207. {
  2208. // User player 1 options...
  2209. opt_user=1;
  2210. }
  2211. else
  2212. // No user players...
  2213. opt_user=-1;
  2214. }
  2215. if ((keys[0x3c] || (users_dir[1].f&8 && users_dir[1].f&4) && !(users_dir[0].f&48)) && num_of_users>=2)
  2216. {
  2217. // User player 2 options...
  2218. opt_user=2;
  2219. }
  2220. if ((keys[0x3d] || (users_dir[2].f&8 && users_dir[2].f&4) && !(users_dir[0].f&48)) && num_of_users>=3)
  2221. {
  2222. // User player 3 options...
  2223. opt_user=3;
  2224. }
  2225. if ((keys[0x3e] || (users_dir[3].f&8 && users_dir[3].f&4) && !(users_dir[0].f&48)) && num_of_users>=4)
  2226. {
  2227. // User player 4 options...
  2228. opt_user=4;
  2229. }
  2230. #else
  2231. if (keys[0x3b] && !keys[0x1d]) // F1
  2232. {
  2233. if (num_of_users>=1)
  2234. {
  2235. // User player 1 options...
  2236. opt_user=1;
  2237. }
  2238. else
  2239. // No user players...
  2240. opt_user=-1;
  2241. }
  2242. if (keys[0x3c] && !keys[0x1d] && num_of_users>=2) // F2
  2243. {
  2244. // User player 2 options...
  2245. opt_user=2;
  2246. }
  2247. if (keys[0x3d] && !keys[0x1d] && num_of_users>=3) // F3
  2248. {
  2249. // User player 3 options...
  2250. opt_user=3;
  2251. }
  2252. if (keys[0x3e] && !keys[0x1d] && num_of_users>=4) // F4
  2253. {
  2254. // User player 4 options...
  2255. opt_user=4;
  2256. }
  2257. #endif
  2258. if (opt_user)
  2259. {
  2260. if (users[opt_user-1].type==-1)
  2261. opt_team=team_a;
  2262. else
  2263. if (users[opt_user-1].type==-2)
  2264. opt_team=team_b;
  2265. else
  2266. if (users[opt_user-1].type<12)
  2267. opt_team=team_a;
  2268. else
  2269. opt_team=team_b;
  2270. }
  2271. }
  2272. }
  2273. else
  2274. if (anykey)
  2275. end_game=TRUE;
  2276. }
  2277. /******************************************************************************
  2278. *****************************************************************************/
  2279. void animate_players()
  2280. {
  2281. for (int i=0; i<players; i++)
  2282. {
  2283. teams[i].tm_frm+=teams[i].tm_fstep;
  2284. }
  2285. for (i=0; i<3; i++)
  2286. {
  2287. refs[i].frm+=refs[i].fstep;
  2288. }
  2289. }
  2290. /******************************************************************************
  2291. *****************************************************************************/
  2292. void update_2d()
  2293. {
  2294. if (plot_buffer)
  2295. plot_cnta=1;
  2296. else
  2297. plot_cntb=1;
  2298. _setplotaction(_GPSET);
  2299. process_butts();
  2300. _setplotaction(_GXOR);
  2301. if (Mouse.b&&1)
  2302. mouse_fired();
  2303. draw_ball();
  2304. draw_team();
  2305. draw_buffer();
  2306. plot_buffer=!plot_buffer;
  2307. draw_buffer();
  2308. delay(delay_cnt);
  2309. panel_data();
  2310. }
  2311. /******************************************************************************
  2312. *****************************************************************************/
  2313. void reset_possession()
  2314. {
  2315. poss_held=0;
  2316. possession=0;
  2317. }
  2318. /******************************************************************************
  2319. *****************************************************************************/
  2320. void accumulate_possession()
  2321. {
  2322. if (ball_poss>11)
  2323. {
  2324. // Team b. currently has possession...
  2325. poss_held+=(0.0001+(ABS(poss_held)/30));
  2326. if (poss_held>0.5)
  2327. poss_held=0.5;
  2328. }
  2329. else
  2330. {
  2331. if (ball_poss)
  2332. // Team a. currently has possession...
  2333. {
  2334. poss_held-=(0.0001+(ABS(poss_held)/30));
  2335. if (poss_held<-0.5)
  2336. poss_held=-0.5;
  2337. }
  2338. }
  2339. if (!ball_poss)
  2340. {
  2341. // Ball is free...(tend slowly towards 0)
  2342. poss_held+=(-poss_held/60);
  2343. }
  2344. possession+=poss_held;
  2345. if (possession>1)
  2346. possession=1;
  2347. if (possession<-1)
  2348. possession=-1;
  2349. }
  2350. /******************************************************************************
  2351. *****************************************************************************/
  2352. void process_crowd_noise()
  2353. {
  2354. if (shot_missed)
  2355. {
  2356. if (shot_missed<0)
  2357. {
  2358. // Missed by a long way...
  2359. shot_missed++;
  2360. if (last_touch<12)
  2361. {
  2362. // team A shot...
  2363. crowd_mood_a=CN_BOO;
  2364. crowd_mood_b=CN_LAUGH;
  2365. }
  2366. else
  2367. {
  2368. // team B shot...
  2369. crowd_mood_a=CN_LAUGH;
  2370. crowd_mood_b=CN_BOO;
  2371. }
  2372. }
  2373. else
  2374. {
  2375. // Near missed...
  2376. shot_missed--;
  2377. if (last_touch<12)
  2378. {
  2379. // team A shot...
  2380. crowd_mood_a=CN_MISS;
  2381. crowd_mood_b=CN_PENSIVE;
  2382. }
  2383. else
  2384. {
  2385. // team B shot...
  2386. crowd_mood_a=CN_PENSIVE;
  2387. crowd_mood_b=CN_MISS;
  2388. }
  2389. }
  2390. }
  2391. else
  2392. {
  2393. if (shot_saved)
  2394. {
  2395. // Shot stopped...
  2396. shot_saved--;
  2397. if (last_touch<12)
  2398. {
  2399. // team A save...
  2400. crowd_mood_a=CN_SAVE;
  2401. crowd_mood_b=CN_MISS;
  2402. }
  2403. else
  2404. {
  2405. // team B save...
  2406. crowd_mood_a=CN_MISS;
  2407. crowd_mood_b=CN_SAVE;
  2408. }
  2409. }
  2410. else
  2411. {
  2412. if (card_is_out)
  2413. {
  2414. card_is_out--;
  2415. crowd_mood_a=CN_FOWL;
  2416. crowd_mood_b=CN_FOWL;
  2417. }
  2418. else
  2419. {
  2420. if (match_half>10)
  2421. {
  2422. // End of Game...
  2423. crowd_mood_a=CN_EXCITED;
  2424. crowd_mood_b=CN_EXCITED;
  2425. }
  2426. else
  2427. {
  2428. switch(match_mode)
  2429. {
  2430. case(NORMAL_PLAY):
  2431. if (shot_pending && shot_acknowledged)
  2432. {
  2433. // Keeper is reacting to incoming ball...
  2434. if (ballx<prat*40 && ballxdis<0 && last_touch>11)
  2435. {
  2436. // Ball coming left (from team B)...
  2437. crowd_mood_a=CN_PENSIVE;
  2438. crowd_mood_b=CN_EXCITED;
  2439. }
  2440. if (ballx>(pitch_len-(prat*40)) && ballxdis>0 && last_touch<12)
  2441. {
  2442. // Ball coming right (from team A)...
  2443. crowd_mood_a=CN_EXCITED;
  2444. crowd_mood_b=CN_PENSIVE;
  2445. }
  2446. }
  2447. else
  2448. {
  2449. accumulate_possession();
  2450. if (ball_in_hands && (ball_poss==KP_A || ball_poss==KP_B))
  2451. {
  2452. // Keepers ball...(calm)
  2453. crowd_mood_a=CN_NORMAL;
  2454. crowd_mood_b=CN_NORMAL;
  2455. }
  2456. else
  2457. {
  2458. if ((ballx>(cntspot_x-prat*16)) && (ballx<(cntspot_x+prat*16)))
  2459. {
  2460. // In mid-field...
  2461. crowd_mood_a=CN_NORMAL;
  2462. crowd_mood_b=CN_NORMAL;
  2463. }
  2464. else
  2465. {
  2466. if (ballx<=(cntspot_x-prat*16))
  2467. {
  2468. // Near Goal A...
  2469. if (possession>0.5)
  2470. {
  2471. // Team B has good possession...
  2472. crowd_mood_a=CN_PENSIVE;
  2473. crowd_mood_b=CN_EXCITED;
  2474. }
  2475. else
  2476. {
  2477. if (possession<-0.5)
  2478. {
  2479. // Defending team A has it under control...
  2480. crowd_mood_a=CN_NORMAL;
  2481. crowd_mood_b=CN_NORMAL;
  2482. }
  2483. else
  2484. {
  2485. // No one team has it under control...
  2486. crowd_mood_a=CN_NORMAL;
  2487. crowd_mood_b=CN_ENCOURAGING;
  2488. }
  2489. }
  2490. }
  2491. else
  2492. {
  2493. // Near Goal B...
  2494. if (possession<-0.5)
  2495. {
  2496. // Team A has good possession...
  2497. crowd_mood_a=CN_EXCITED;
  2498. crowd_mood_b=CN_PENSIVE;
  2499. }
  2500. else
  2501. {
  2502. if (possession>0.5)
  2503. {
  2504. // Defending team B has it under control...
  2505. crowd_mood_a=CN_NORMAL;
  2506. crowd_mood_b=CN_NORMAL;
  2507. }
  2508. else
  2509. {
  2510. // No one team has it under control...
  2511. crowd_mood_a=CN_ENCOURAGING;
  2512. crowd_mood_b=CN_NORMAL;
  2513. }
  2514. }
  2515. }
  2516. }
  2517. }
  2518. if (just_scored)
  2519. {
  2520. // someone has scored a goal...
  2521. if (ballx<cntspot_x)
  2522. {
  2523. // Team A. goal...
  2524. if (goal_scorer>11)
  2525. {
  2526. // Team B scores good goal!
  2527. crowd_mood_a=CN_PENSIVE;
  2528. crowd_mood_b=CN_CELEBRATE;
  2529. }
  2530. else
  2531. {
  2532. // Team A scores own goal!
  2533. crowd_mood_a=CN_BOO;
  2534. crowd_mood_b=CN_CELEBRATE;
  2535. }
  2536. }
  2537. else
  2538. {
  2539. // Team B. goal...
  2540. if (goal_scorer<12)
  2541. {
  2542. // Team A scores good goal!
  2543. crowd_mood_a=CN_CELEBRATE;
  2544. crowd_mood_b=CN_PENSIVE;
  2545. }
  2546. else
  2547. {
  2548. // Team B scores own goal!
  2549. crowd_mood_a=CN_CELEBRATE;
  2550. crowd_mood_b=CN_BOO;
  2551. }
  2552. }
  2553. }
  2554. }
  2555. break;
  2556. case(DF_KICK_B):
  2557. if (!men_in_wall) // Not in shooting range!
  2558. {
  2559. if ((ballx>(cntspot_x-prat*16)) && (ballx<(cntspot_x+prat*16)))
  2560. {
  2561. // In mid-field...
  2562. crowd_mood_a=CN_NORMAL;
  2563. crowd_mood_b=CN_NORMAL;
  2564. }
  2565. else
  2566. {
  2567. if (ballx<=(cntspot_x-prat*16))
  2568. {
  2569. // Near Goal A...
  2570. crowd_mood_a=CN_PENSIVE;
  2571. crowd_mood_b=CN_ENCOURAGING;
  2572. }
  2573. else
  2574. {
  2575. // Near Own Goal B...
  2576. crowd_mood_a=CN_NORMAL;
  2577. crowd_mood_b=CN_NORMAL;
  2578. }
  2579. }
  2580. break;
  2581. }
  2582. case(CORNER_TL):
  2583. case(CORNER_BL):
  2584. crowd_mood_a=CN_PENSIVE;
  2585. crowd_mood_b=CN_EXCITED;
  2586. break;
  2587. case(DF_KICK_A):
  2588. if (!men_in_wall) // Not in shooting range!
  2589. {
  2590. if ((ballx>(cntspot_x-prat*16)) && (ballx<(cntspot_x+prat*16)))
  2591. {
  2592. // In mid-field...
  2593. crowd_mood_a=CN_NORMAL;
  2594. crowd_mood_b=CN_NORMAL;
  2595. }
  2596. else
  2597. {
  2598. if (ballx>=(cntspot_x+prat*16))
  2599. {
  2600. // Near Goal B...
  2601. crowd_mood_a=CN_ENCOURAGING;
  2602. crowd_mood_b=CN_PENSIVE;
  2603. }
  2604. else
  2605. {
  2606. // Near Own Goal A...
  2607. crowd_mood_a=CN_NORMAL;
  2608. crowd_mood_b=CN_NORMAL;
  2609. }
  2610. }
  2611. break;
  2612. }
  2613. case(CORNER_TR):
  2614. case(CORNER_BR):
  2615. crowd_mood_a=CN_EXCITED;
  2616. crowd_mood_b=CN_PENSIVE;
  2617. break;
  2618. case(GOAL_KICK_TL):
  2619. case(GOAL_KICK_TR):
  2620. case(GOAL_KICK_BL):
  2621. case(GOAL_KICK_BR):
  2622. crowd_mood_a=CN_NORMAL;
  2623. crowd_mood_b=CN_NORMAL;
  2624. reset_possession();
  2625. break;
  2626. case(IF_KICK_A):
  2627. case(THROW_IN_A):
  2628. if ((ballx>(cntspot_x-prat*16)) && (ballx<(cntspot_x+prat*16)))
  2629. {
  2630. // In mid-field...
  2631. crowd_mood_a=CN_NORMAL;
  2632. crowd_mood_b=CN_NORMAL;
  2633. }
  2634. else
  2635. {
  2636. if (ballx>=(cntspot_x+prat*16))
  2637. {
  2638. // Near Goal B...
  2639. crowd_mood_a=CN_ENCOURAGING;
  2640. crowd_mood_b=CN_PENSIVE;
  2641. }
  2642. else
  2643. {
  2644. // Near Own Goal A...
  2645. crowd_mood_a=CN_NORMAL;
  2646. crowd_mood_b=CN_NORMAL;
  2647. }
  2648. }
  2649. break;
  2650. case(IF_KICK_B):
  2651. case(THROW_IN_B):
  2652. if ((ballx>(cntspot_x-prat*16)) && (ballx<(cntspot_x+prat*16)))
  2653. {
  2654. // In mid-field...
  2655. crowd_mood_a=CN_NORMAL;
  2656. crowd_mood_b=CN_NORMAL;
  2657. }
  2658. else
  2659. {
  2660. if (ballx<=(cntspot_x-prat*16))
  2661. {
  2662. // Near Goal A...
  2663. crowd_mood_a=CN_PENSIVE;
  2664. crowd_mood_b=CN_ENCOURAGING;
  2665. }
  2666. else
  2667. {
  2668. // Near Own Goal B...
  2669. crowd_mood_a=CN_NORMAL;
  2670. crowd_mood_b=CN_NORMAL;
  2671. }
  2672. }
  2673. break;
  2674. case(PEN_KICK_A):
  2675. case(PEN_KICK_B):
  2676. case(SWAP_ENDS):
  2677. crowd_mood_a=CN_EXCITED;
  2678. crowd_mood_b=CN_EXCITED;
  2679. break;
  2680. case(CENTRE_A):
  2681. case(CENTRE_B):
  2682. reset_possession();
  2683. if (kickoff)
  2684. {
  2685. crowd_mood_a=CN_EXCITED;
  2686. crowd_mood_b=CN_EXCITED;
  2687. }
  2688. else
  2689. {
  2690. crowd_mood_a=CN_NORMAL;
  2691. crowd_mood_b=CN_NORMAL;
  2692. }
  2693. break;
  2694. }
  2695. }
  2696. }
  2697. }
  2698. }
  2699. }
  2700. /******************************************************************************
  2701. *****************************************************************************/
  2702. char nothing_happening()
  2703. {
  2704. if (!match_mode && !just_scored)
  2705. {
  2706. // In Play...
  2707. play_fx(PS_FULLTIMEWHISTLE,refs[0].x,refs[0].y);
  2708. if (shot_pending || dead_ball_cnt || game_action)
  2709. return(FALSE); // Crucial moment!
  2710. else
  2711. return(TRUE);
  2712. }
  2713. else
  2714. {
  2715. if (match_mode<=CORNER_BR || match_mode>=PEN_KICK_A)
  2716. return(FALSE); // Crucial moment!
  2717. else
  2718. if ((match_mode==DF_KICK_B || match_mode==DF_KICK_A) && men_in_wall)
  2719. return(FALSE); // Crucial moment!
  2720. else
  2721. return(TRUE);
  2722. }
  2723. }
  2724. /******************************************************************************
  2725. *****************************************************************************/
  2726. void watch_match_time()
  2727. {
  2728. if (golden_goal==2 && !just_scored)
  2729. {
  2730. // End of sudden death...
  2731. if (match_half<11)
  2732. {
  2733. // Start leaving field!
  2734. play_fx(PS_FULLTIMEWHISTLE,refs[0].x,refs[0].y);
  2735. last_goal=0;
  2736. match_mode=SWAP_ENDS;
  2737. init_match_mode();
  2738. do_full_time_anim(0);
  2739. do_fulltime_menu();
  2740. match_half=11; // End game!
  2741. PlayCommentaryMessage(TI_FULLTIME);
  2742. next_mins=0;
  2743. #ifdef EURO96
  2744. get_performance();
  2745. xinfo=9;
  2746. if (man_of_match)
  2747. camera=18;
  2748. #endif
  2749. }
  2750. }
  2751. else
  2752. {
  2753. if (match_info.CompetitionType==PENALTIES)
  2754. {
  2755. // Practice penalties...
  2756. if (!penalty_game)
  2757. {
  2758. if (team_a_goals!=team_b_goals)
  2759. {
  2760. // Someone has won shoot-out...
  2761. if (match_half<11)
  2762. {
  2763. // Initialise end of penalty shoot-out...
  2764. last_goal=0;
  2765. match_mode=SWAP_ENDS;
  2766. init_match_mode();
  2767. do_full_time_anim(0);
  2768. EUROmatch_info.Team_A_penalties=team_a_goals;
  2769. EUROmatch_info.Team_B_penalties=team_b_goals;
  2770. do_final_score_menu();
  2771. match_half=11; // End game!
  2772. PlayCommentaryMessage(TI_FULLTIME);
  2773. next_mins=0;
  2774. #ifdef EURO96
  2775. get_performance();
  2776. xinfo=9;
  2777. if (man_of_match)
  2778. camera=18;
  2779. #endif
  2780. }
  2781. }
  2782. else
  2783. {
  2784. // Initialise penalty shoot-out...
  2785. EUROmatch_info.penalties=TRUE;
  2786. penalty_game=TRUE;
  2787. team_a_goals=0;
  2788. team_b_goals=0;
  2789. EUROmatch_info.Team_A_penalties=team_a_goals;
  2790. EUROmatch_info.Team_B_penalties=team_b_goals;
  2791. do_penalty_shootout_menu();
  2792. next_mins=0;
  2793. }
  2794. }
  2795. }
  2796. else
  2797. {
  2798. if (match_time.min>=(45+injury_time) && !match_half && nothing_happening())
  2799. {
  2800. // End of first half! (It's a game of two halves...)
  2801. #ifdef DEMO
  2802. last_goal=0;
  2803. match_mode=SWAP_ENDS;
  2804. init_match_mode();
  2805. play_fx(PS_FULLTIMEWHISTLE,refs[0].x,refs[0].y);
  2806. do_full_time_anim(0);
  2807. do_fulltime_menu();
  2808. PlayCommentaryMessage(TI_FULLTIME);
  2809. match_half=11; // End game!
  2810. next_mins=0;
  2811. #else
  2812. match_mode=SWAP_ENDS;
  2813. last_goal=0;
  2814. init_match_mode();
  2815. play_fx(PS_HALFTIMEWHISTLE,refs[0].x,refs[0].y);
  2816. do_half_time_anim(0);
  2817. do_halftime_menu();
  2818. PlayCommentaryMessage(TI_HALFTIME);
  2819. kickoff=TRUE;
  2820. next_mins=45;
  2821. if (practice)
  2822. match_half=12;
  2823. #endif
  2824. }
  2825. else
  2826. {
  2827. if (match_time.min>=(90+injury_time) && match_half==1 && nothing_happening())
  2828. {
  2829. // End of full time! (Not half mate...)
  2830. last_goal=0;
  2831. match_mode=SWAP_ENDS;
  2832. init_match_mode();
  2833. play_fx(PS_FULLTIMEWHISTLE,refs[0].x,refs[0].y);
  2834. if (need_result && team_a_goals==team_b_goals)
  2835. {
  2836. do_extra_time_anim(0);
  2837. do_extratime_menu();
  2838. EUROmatch_info.extra=TRUE;
  2839. kickoff=TRUE;
  2840. next_mins=90;
  2841. }
  2842. else
  2843. {
  2844. do_full_time_anim(0);
  2845. do_fulltime_menu();
  2846. PlayCommentaryMessage(TI_FULLTIME);
  2847. match_half=11; // End game!
  2848. next_mins=0;
  2849. #ifdef EURO96
  2850. get_performance();
  2851. xinfo=9;
  2852. if (man_of_match)
  2853. camera=18;
  2854. #endif
  2855. }
  2856. }
  2857. else
  2858. {
  2859. if (need_result && match_time.min>=(90+15+injury_time)
  2860. && match_half==2 && nothing_happening())
  2861. // End of first half of extra time! (It's a game with more halves...)
  2862. {
  2863. last_goal=0;
  2864. match_mode=SWAP_ENDS;
  2865. init_match_mode();
  2866. do_half_time_anim(0);
  2867. do_halftime_menu();
  2868. play_fx(PS_HALFTIMEWHISTLE,refs[0].x,refs[0].y);
  2869. kickoff=TRUE;
  2870. next_mins=105;
  2871. }
  2872. else
  2873. {
  2874. if (!penalty_game && need_result && match_time.min>=(90+30+injury_time)
  2875. && match_half==3 && nothing_happening())
  2876. // End of full extra time!
  2877. {
  2878. play_fx(PS_FULLTIMEWHISTLE,refs[0].x,refs[0].y);
  2879. if (need_result && team_a_goals==team_b_goals)
  2880. {
  2881. EUROmatch_info.penalties=TRUE;
  2882. penalty_game=TRUE;
  2883. team_a_goals=0;
  2884. team_b_goals=0;
  2885. EUROmatch_info.Team_A_penalties=team_a_goals;
  2886. EUROmatch_info.Team_B_penalties=team_b_goals;
  2887. do_penalty_shootout_menu();
  2888. next_mins=0;
  2889. }
  2890. else
  2891. {
  2892. last_goal=0;
  2893. match_mode=SWAP_ENDS;
  2894. init_match_mode();
  2895. do_full_time_anim(0);
  2896. if (EUROmatch_info.penalties)
  2897. {
  2898. EUROmatch_info.Team_A_penalties=team_a_goals;
  2899. EUROmatch_info.Team_B_penalties=team_b_goals;
  2900. do_final_score_menu();
  2901. }
  2902. else
  2903. do_fulltime_menu();
  2904. match_half=11; // End game!
  2905. PlayCommentaryMessage(TI_FULLTIME);
  2906. next_mins=0;
  2907. #ifdef EURO96
  2908. get_performance();
  2909. xinfo=9;
  2910. if (man_of_match)
  2911. camera=18;
  2912. #endif
  2913. }
  2914. }
  2915. }
  2916. }
  2917. }
  2918. }
  2919. }
  2920. }
  2921. /******************************************************************************
  2922. *****************************************************************************/
  2923. void setup_alarm()
  2924. {
  2925. mf_fixed=FALSE;
  2926. alarm=FALSE; // Debug alarm on/off.
  2927. watch=TRUE;
  2928. stop_min=45;
  2929. stop_sec=1; // Debug alarm stop.
  2930. }
  2931. /******************************************************************************
  2932. *****************************************************************************/
  2933. void init_wind()
  2934. {
  2935. // Wind stuff...
  2936. if (EUROmatch_info.wind)
  2937. {
  2938. init_wind_x=1;
  2939. init_wind_y=0;
  2940. wind_x=init_wind_x;
  2941. wind_y=init_wind_y;
  2942. init_wind_speed=EUROmatch_info.wind*30; // (30,60,90)
  2943. wind_speed=init_wind_speed;
  2944. wind_var_ang=0;
  2945. wind_d_trend=0;
  2946. wind_s_trend=0;
  2947. af_randomize();
  2948. if (!(seed&3))
  2949. wind_on=-TRUE; // Variable wind!
  2950. else
  2951. wind_on=TRUE;
  2952. wind_on=TRUE;
  2953. }
  2954. else
  2955. wind_on=FALSE;
  2956. }
  2957. /******************************************************************************
  2958. *****************************************************************************/
  2959. // Get your grubby mits off these routines Andy!
  2960. void NetUserInit()
  2961. {
  2962. if (network_on)
  2963. {
  2964. // Network init users
  2965. for (int i=0;i<network_on;i++)
  2966. {
  2967. int ctrl;
  2968. if (i==wConsoleNode)
  2969. {
  2970. ctrl=convert_control(match_info.control_methods[0]);
  2971. // ctrl=KEY1_CTRL;
  2972. // calibrate_joy(0,&joy1_cnt_x,&joy1_cnt_y);
  2973. }
  2974. else
  2975. ctrl=NET_CTRL;
  2976. if (NetTeams[i]==0)
  2977. if (Players[i]==1)
  2978. add_team_user(TEAM_A,ctrl);
  2979. else
  2980. add_fixed_user(Players[i],ctrl);
  2981. else
  2982. if (Players[i]==1)
  2983. add_team_user(TEAM_B,ctrl);
  2984. else
  2985. add_fixed_user(Players[i]+11,ctrl);
  2986. }
  2987. }
  2988. }
  2989. int otick;
  2990. void TimerInit()
  2991. {
  2992. ftick=0;
  2993. otick=tick=0;
  2994. old_count=count;
  2995. /*
  2996. if (!old_mf)
  2997. {
  2998. get_user_inputs();
  2999. process_user_inputs();
  3000. writeptr++;
  3001. }
  3002. */
  3003. while(tick==otick);
  3004. }
  3005. /******************************************************************************
  3006. *****************************************************************************/
  3007. void reset_front()
  3008. {
  3009. for (int i=0; i<sizeof(cam_array); i++)
  3010. {
  3011. if (camera==cam_array[i])
  3012. {
  3013. EUROmatch_info.camera=i;
  3014. match_info.camera_toggle=i;
  3015. break;
  3016. }
  3017. }
  3018. }
  3019. /******************************************************************************
  3020. *****************************************************************************/
  3021. int match(int argc, char **argv)
  3022. {
  3023. int match_err=FALSE;
  3024. initialise_vars();
  3025. #ifdef NET_GAME
  3026. // Pseudo net initialisation (not normally used)
  3027. NetTest();
  3028. #endif
  3029. if (network_on)
  3030. old_mf=FALSE;
  3031. else
  3032. old_mf=TRUE;
  3033. offside_on=EUROmatch_info.offside;
  3034. if (match_info.CompetitionType==PRACTICE)
  3035. {
  3036. offside_on=FALSE;
  3037. }
  3038. // Set up default camera...
  3039. camera=cam_array[EUROmatch_info.camera];
  3040. float cd=set_camera_dist;
  3041. float ch=set_camera_height;
  3042. change_cam(camera);
  3043. set_camera_dist=cd;
  3044. set_camera_height=ch;
  3045. // Set up audio...
  3046. audio_version=(char)EUROmatch_info.audio;
  3047. // Vidi screen setup...
  3048. vidi_wall_on=(char)EUROmatch_info.vidi; // Vidi toggle!
  3049. // Debugging alarm...
  3050. setup_alarm();
  3051. #ifndef FRONT_END
  3052. time_factor=4;
  3053. // debug=TRUE; // Allows return keyboard to dos.
  3054. #else
  3055. say_names=TRUE;
  3056. if (network_on)
  3057. time_factor=time_table[net_half]; // Real minutes duration.
  3058. else
  3059. time_factor=time_table[EUROmatch_info.time]; // Real minutes duration.
  3060. debug=FALSE; // Allows return keyboard to dos.
  3061. #endif
  3062. #ifdef ECTS
  3063. time_factor=4;
  3064. #endif
  3065. // debug=TRUE;
  3066. // time_factor=10;
  3067. init_wind();
  3068. gravity=0.60;
  3069. on_3d=TRUE;
  3070. digital_joy1=FALSE;
  3071. digital_joy2=FALSE;
  3072. close_in_number=2;
  3073. goal_kicker_a=1;
  3074. goal_kicker_b=12;
  3075. fkick_taker_a=0;
  3076. fkick_taker_b=0;
  3077. corn_kicker_a=0;
  3078. corn_kicker_b=0;
  3079. // _setvideomode(_MRES256COLOR);
  3080. init_officials();
  3081. init_match();
  3082. if (!on_3d)
  3083. {
  3084. plot_buffer=TRUE;
  3085. plot_cnta=0;
  3086. plot_cntb=0;
  3087. draw_pitch();
  3088. pitch_markings();
  3089. _setcolor(4);
  3090. draw_buttons();
  3091. _setcolor(50);
  3092. _setplotaction(_GXOR);
  3093. ShowMouse();
  3094. MouseYlim(140,200-4);
  3095. MouseXlim(160*2,(320-4)*2);
  3096. }
  3097. else
  3098. {
  3099. if (init_3d()<0)
  3100. goto ERR_3D;
  3101. MouseYlim(0,200);
  3102. MouseXlim(0,320);
  3103. }
  3104. if (audio_version)
  3105. {
  3106. InitMatchAudio(rand_seed);
  3107. if (!LoadPitchSamples())
  3108. if (!LoadTeamSamples(setup.team_a,HOME_TEAM))
  3109. if (!LoadTeamSamples(setup.team_b,AWAY_TEAM))
  3110. {
  3111. if (match_info.CompetitionType!=PRACTICE)
  3112. LoadCommentarySamples();
  3113. StartCrowd(HOME_TEAM);
  3114. StartCrowd(AWAY_TEAM);
  3115. }
  3116. }
  3117. // Pseudo net user initialisation (not normally used)
  3118. NetUserInit();
  3119. users_left=num_of_users;
  3120. // Wait for everyone to get here, set timer & machine factor...
  3121. readptr=writeptr=0;
  3122. Network_Play_Ready();
  3123. setscreen();
  3124. if (audio_version)
  3125. PlayWelcomeMessage();
  3126. // Various timing initialisations for network (DO NOT MOVE)
  3127. TimerInit();
  3128. mf_scale=omf_scale=0.5;
  3129. MF=1;
  3130. old_clock=clock();
  3131. oldcnt=count;
  3132. // No Dos. keyboard chain!
  3133. return_doskey=FALSE;
  3134. // Main program loop...
  3135. // penalty_game=TRUE;
  3136. #ifdef NET_DEBUG
  3137. if (network_on)
  3138. opendebugfile();
  3139. #endif
  3140. do_ref_menu();
  3141. #ifdef FRONT_END
  3142. if (!num_of_users)
  3143. {
  3144. // No Players... Rolling match...
  3145. anykey=FALSE;
  3146. rolling_clock=80*REAL_SPEED;
  3147. demo_match=TRUE;
  3148. }
  3149. #endif
  3150. // out_mcball_coords();
  3151. // old_mf=0;
  3152. while (in_game && !net_quit)
  3153. {
  3154. /***********************************************/
  3155. if (!old_mf) // New logical loop
  3156. {
  3157. int ttick=tick;
  3158. int tftick=ftick;
  3159. int twriteptr=writeptr;
  3160. if ((mf_fixed) || (!on_3d) || (!watch && alarm))
  3161. ttick=tick=otick+1,tftick=ftick=0,mf_scale=omf_scale=0;
  3162. mf_scale=(float)tftick/TIMER_SPEED;
  3163. MF=(ttick+mf_scale)-(otick+omf_scale);
  3164. omf_scale=mf_scale;
  3165. log_factor=MF; // Passed to 3d (Logic cycles/update)
  3166. for (int i=readptr; i!=twriteptr; ++i&=511)
  3167. {
  3168. process_crowd_noise();
  3169. if (audio_version)
  3170. {
  3171. process_crowd_noise();
  3172. UpdateCrowd(crowd_mood_a,team_a);
  3173. UpdateCrowd(crowd_mood_b,team_b);
  3174. UpdateCommentary();
  3175. }
  3176. wptr=writeptr;
  3177. rptr=readptr;
  3178. convert_inputs();
  3179. readptr++;
  3180. readptr&=511;
  3181. if (!line_up)
  3182. {
  3183. do_logic();
  3184. }
  3185. else
  3186. {
  3187. line_up--;
  3188. animate_players();
  3189. if (!line_up)
  3190. {
  3191. match_mode=CENTRE_A;
  3192. init_match_mode();
  3193. }
  3194. }
  3195. #ifdef EURO96
  3196. process_state();
  3197. #else
  3198. logic_cnt++;
  3199. #endif
  3200. #ifdef NET_DEBUG
  3201. if (network_on)
  3202. {
  3203. writeplayerdata();
  3204. writecontroldata(i);
  3205. }
  3206. #endif
  3207. new_update_coords();
  3208. process_replay();
  3209. watch_match_time();
  3210. }
  3211. otick=ttick;
  3212. }
  3213. else
  3214. {
  3215. if ((mf_fixed) || (!on_3d) || (!watch && alarm))
  3216. MF=1;
  3217. mf_scale+=MF;
  3218. log_factor=MF; // Passed to 3d(Logic cycles/update)
  3219. for (float i=(mf_scale); (i>1); i=i-1)
  3220. {
  3221. process_crowd_noise();
  3222. if (audio_version)
  3223. {
  3224. process_crowd_noise();
  3225. UpdateCrowd(crowd_mood_a,team_a);
  3226. UpdateCrowd(crowd_mood_b,team_b);
  3227. UpdateCommentary();
  3228. }
  3229. get_user_inputs();
  3230. process_user_inputs();
  3231. writeptr++;
  3232. writeptr&=511;
  3233. convert_inputs();
  3234. readptr++;
  3235. readptr&=511;
  3236. if (!line_up)
  3237. {
  3238. do_logic();
  3239. }
  3240. else
  3241. {
  3242. line_up--;
  3243. animate_players();
  3244. if (!line_up)
  3245. {
  3246. match_mode=CENTRE_A;
  3247. init_match_mode();
  3248. }
  3249. }
  3250. #ifdef EURO96
  3251. process_state();
  3252. #else
  3253. logic_cnt++;
  3254. #endif
  3255. new_update_coords();
  3256. process_replay();
  3257. watch_match_time();
  3258. mf_scale=mf_scale-1;
  3259. }
  3260. }
  3261. /***********************************************/
  3262. if (!(!watch && alarm))
  3263. {
  3264. realtime_coords();
  3265. process_pitch_sprs();
  3266. if (keys[0x01] && !escape_pending) // (Esc.)
  3267. {
  3268. escape_pending=TRUE;
  3269. add_message("Quit Game Y or N",RED,TRUE);
  3270. }
  3271. if (on_3d)
  3272. update_3d();
  3273. else
  3274. update_2d();
  3275. if (on_3d)
  3276. {
  3277. if (old_mf)
  3278. {
  3279. frame_count();
  3280. }
  3281. else
  3282. updates++;
  3283. process_keys();
  3284. }
  3285. }
  3286. if (demo_match && rolling_clock<=0)
  3287. end_game=TRUE;
  3288. if ((!on_3d) && (delay_cnt))
  3289. delay(delay_cnt);
  3290. if (!in_game && !on_3d)
  3291. {
  3292. editor_main();
  3293. break;
  3294. }
  3295. if (escape_pending<0)
  3296. {
  3297. // Quit Match...
  3298. net_error=-1;
  3299. break;
  3300. }
  3301. if (end_game)
  3302. break;
  3303. }
  3304. #ifdef NET_DEBUG
  3305. if (network_on)
  3306. closedebugfile();
  3307. #endif
  3308. // Remove network (if appropriate)
  3309. Quit_Network_Play();
  3310. if (audio_version)
  3311. {
  3312. StopAudio();
  3313. }
  3314. end3d(); // Goodbye Laurent's crappy heap of runny donkey shit code...
  3315. freex(replay_tab);
  3316. #ifdef COVERDISK
  3317. do{
  3318. }while(keys[0x01]);
  3319. display_endscr();
  3320. #endif
  3321. // Inform front end on times...
  3322. if (end_game)
  3323. {
  3324. // Played Full Match!!!
  3325. EUROmatch_info.return_mins=-1;
  3326. }
  3327. else
  3328. {
  3329. // Escaped from match!!!
  3330. EUROmatch_info.return_mins=match_time.min;
  3331. }
  3332. if (audio_version)
  3333. {
  3334. FreeCommentarySamples();
  3335. FreeTeamSamples(AWAY_TEAM);
  3336. FreeTeamSamples(HOME_TEAM);
  3337. FreePitchSamples();
  3338. }
  3339. // Give back front end enviroment stuff...
  3340. reset_front();
  3341. // Give Dos. keyboard chain!
  3342. #ifdef MEG4
  3343. release_key_int();
  3344. #endif
  3345. return_doskey=TRUE;
  3346. return(FALSE); // No errors...
  3347. /************ ERRORS *************/
  3348. /*********/
  3349. ERR_3D:;
  3350. // Remove network (if appropriate)
  3351. net_error=-1;
  3352. Quit_Network_Play();
  3353. match_err+=256;
  3354. goto RETURN_ERR;
  3355. /*********/
  3356. RETURN_ERR:;
  3357. return(match_err);
  3358. }