home *** CD-ROM | disk | FTP | other *** search
/ Revista CD Expert 51 / PCGamer51_17Demos.iso / games / CM / CyclingManagerDemoCangas.exe / CyclingManagerDemo / scripts / inrace / page_inrace.cnc < prev    next >
Text File  |  2001-07-02  |  85KB  |  2,852 lines

  1.  
  2. func void RefreshInfos ()
  3. {
  4.     //Update the informations about the cyclist and the groups
  5.     // Update Angle picto
  6.     Panel_Inrace_Tab_Update();
  7.     if (GetInRaceMode()==G_iRaceModeTimeTrial)
  8.         Object_InRaceEvents_Time_Trial_Update();
  9.     else if (GetInRaceMode()==G_iRaceModeTeamTimeTrial)
  10.         Object_InRaceEvents_Team_Time_Trial_Update();
  11. }
  12.  
  13. func szx szGetKmDistance(f32x _fDistance)
  14. {
  15.     var i32x iDistance;
  16.     var szx szTemp;
  17.  
  18.     iDistance = _fDistance;
  19.     szTemp = strcat(itoa(iDistance),".");
  20.     _fDistance = _fDistance - iDistance;
  21.     _fDistance = _fDistance * 10.0;
  22.     iDistance = _fDistance;
  23.     szTemp = strcat(szTemp,itoa(iDistance));
  24.     szTemp = strcat(szTemp,"Km");    
  25.  
  26.     return szTemp;
  27. }
  28.  
  29. func szx GetHourMinSecFromTime(f32x _fTime)
  30. {
  31.     var szx szRes;
  32.     var i32x iHour,iMin,iSec;
  33.     var i32x ok;
  34.  
  35.     // Game time to real time compute
  36.     iHour=_fTime/360.0;
  37.     _fTime=_fTime-(iHour*360);
  38.     iMin=_fTime/6.0;
  39.     _fTime=_fTime-(iMin*6);
  40.     iSec=_fTime*10.0;
  41.  
  42.     ok = 0;
  43.     if(iHour>0)
  44.     {
  45.         szRes=itoa(iHour);
  46.         szRes=strcat(szRes, "h");
  47.         ok = 1;
  48.     }
  49.  
  50.     if((iMin>0)||(ok==1))
  51.     {
  52.         if(ok==0)
  53.         {
  54.             szRes=itoa(iMin);
  55.         }
  56.         else
  57.         {
  58.             if(iMin<10)
  59.             {
  60.                 szRes = strcat(szRes,"0");
  61.             }
  62.             szRes=strcat(szRes,itoa(iMin));
  63.         }
  64.         szRes=strcat(szRes, "'");
  65.         ok=1;
  66.     }
  67.     if(ok == 0)
  68.     {
  69.         szRes=itoa(iSec);
  70.     }
  71.     else
  72.     {
  73.         if(iSec<10)
  74.         {
  75.             szRes=strcat(szRes,"0");
  76.         }
  77.         szRes=strcat(szRes,itoa(iSec));
  78.     }
  79.     szRes=strcat(szRes, "''");
  80.     return szRes;    
  81. }
  82. func szx GetFullHMSFromTime(f32x _fTime)
  83. {
  84.     var szx szRes;
  85.     var f32x f;
  86.     var i32x iHour,iMin,iSec,iCent;
  87.     var i32x ok;
  88.  
  89.     // Game time to real time compute
  90.     iHour=_fTime/360.0;
  91.     _fTime=_fTime-(iHour*360);
  92.     iMin=_fTime/6.0;
  93.     _fTime=_fTime-(iMin*6);
  94.     iSec=_fTime*10.0;
  95.     _fTime=_fTime-(0.1*iSec);
  96.     iCent = _fTime*1000.0;
  97.  
  98.     ok = 0;
  99.     if(iHour>0)
  100.     {
  101.         szRes=itoa(iHour);
  102.         szRes=strcat(szRes, "h");
  103.         ok = 1;
  104.     }
  105.  
  106.     if((iMin>0)||(ok==1))
  107.     {
  108.         if(ok==0)
  109.         {
  110.             szRes=itoa(iMin);
  111.         }
  112.         else
  113.         {
  114.             if(iMin<10)
  115.             {
  116.                 szRes = strcat(szRes,"0");
  117.             }
  118.             szRes=strcat(szRes,itoa(iMin));
  119.         }
  120.         szRes=strcat(szRes, "'");
  121.         ok=1;
  122.     }
  123.     if(ok == 0)
  124.     {
  125.         szRes=itoa(iSec);
  126.     }
  127.     else
  128.     {
  129.         if(iSec<10)
  130.         {
  131.             szRes=strcat(szRes,"0");
  132.         }
  133.         szRes=strcat(szRes,itoa(iSec));
  134.         ok=1;
  135.     }
  136.     szRes=strcat(szRes, "''");
  137.  
  138.     if(iCent<10)
  139.         szRes = strcat(szRes,"0");
  140.     szRes = strcat(szRes,itoa(iCent));
  141.  
  142.     return szRes;    
  143. }
  144.  
  145.  
  146. //Race modes :Normal, time trial or team time trial modes
  147. //This mode changes when menuserver send a phase update
  148. func i32x GetRaceMode()
  149. {
  150. /*print("\nGetting race mode debug : g_oMenuJoins.m_iStageTimeTrial=");
  151. print(itoa(g_oMenuJoins.m_iStageTimeTrial));
  152. print("g_oGameConfig.g_iCurrentStageID=");
  153. print(itoa(g_oGameConfig.g_iCurrentStageID));
  154. print("\nRace mode=");
  155.     print(itoa(Join_GetIntFromKey(g_oMenuJoins.m_iStageTimeTrial,g_oGameConfig.g_iCurrentStageID)));*/
  156.     return Join_GetIntFromKey(g_oMenuJoins.m_iStageTimeTrial,g_oGameConfig.m_iCurrentStageID);
  157. }
  158.  
  159. //Race modes :Normal, time trial or team time trial modes
  160. //This mode is set when creating race window and never changed (not available after race window destructor)
  161. func i32x GetInRaceMode()
  162. {
  163.     return oRace.iInRaceMode;
  164. }
  165.  
  166. // State func for profil strafe button
  167. func void StrafeProfil_ButtonState (i32x _iComponentID,i32x _iState)
  168. {
  169.     if(_iState & GUI_State_Activated)
  170.         SetContainerSprite(_iComponentID, 2, 0);
  171.     else
  172.     {
  173.         if(_iState & GUI_State_UnderMouse)
  174.         {
  175.             SetContainerSprite(_iComponentID, 1, 0);
  176.         }
  177.         else
  178.         {
  179.             SetContainerSprite(_iComponentID, 0, 0);
  180.         }
  181.     }
  182.     if((_iState & GUI_State_UnderMouse)&&(GetContainerHelpIndex(_iComponentID)!=0))
  183.     {
  184.         if(ToolBar_GetHelpStringID() != GetContainerHelpIndex(_iComponentID))
  185.             Set_Tool_Bar_TextID(GetContainerHelpIndex(_iComponentID));
  186.     }
  187.     else
  188.     {
  189.         if(ToolBar_GetHelpStringID() == GetContainerHelpIndex(_iComponentID))
  190.             Reset_Tool_Bar_Text();
  191.     }
  192. }
  193. //----------------------------------------------------------------------------------------------------------------//
  194. //----------------------------------------------------------------------------------------------------------------//
  195. // State func for a button
  196. //----------------------------------------------------------------------------------------------------------------//
  197. //----------------------------------------------------------------------------------------------------------------//
  198. func void ButtonSpeedState_1 (i32x _iComponentID,i32x _iState)
  199. {
  200.  
  201.     if(_iState & GUI_State_Checked)
  202.     {
  203.         SetContainerSprite(_iComponentID, 1, 0);
  204.     }
  205.     else
  206.     {
  207.         SetContainerSprite(_iComponentID, 0, 0);
  208.     }
  209.     if((_iState & GUI_State_UnderMouse)&&(GetContainerHelpIndex(_iComponentID)!=0))
  210.     {
  211.         if(ToolBar_GetHelpStringID() != GetContainerHelpIndex(_iComponentID))
  212.             Set_Tool_Bar_TextID(GetContainerHelpIndex(_iComponentID));
  213.         else
  214.             oToolBar.m_iCounter = oToolBar.m_iCounter + 1;
  215.     }
  216.     else
  217.     {
  218. //        if(ToolBar_GetHelpStringID() == GetContainerHelpIndex(_iComponentID))
  219.             Reset_Tool_Bar_Text();
  220.     }
  221. }
  222.  
  223. func void ButtonSpeedState_2 (i32x _iComponentID,i32x _iState)
  224. {
  225.  
  226.     if(_iState & GUI_State_Checked)
  227.     {
  228.         SetContainerSprite(_iComponentID, 3, 0);
  229.     }
  230.     else
  231.     {
  232.         SetContainerSprite(_iComponentID, 2, 0);
  233.     }
  234.     if((_iState & GUI_State_UnderMouse)&&(GetContainerHelpIndex(_iComponentID)!=0))
  235.     {
  236.         if(ToolBar_GetHelpStringID() != GetContainerHelpIndex(_iComponentID))
  237.             Set_Tool_Bar_TextID(GetContainerHelpIndex(_iComponentID));
  238.         else
  239.             oToolBar.m_iCounter = oToolBar.m_iCounter + 1;
  240.     }
  241.     else
  242.     {
  243. //        if(ToolBar_GetHelpStringID() == GetContainerHelpIndex(_iComponentID))
  244.             Reset_Tool_Bar_Text();
  245.     }
  246. }
  247. func void ButtonSpeedState_3 (i32x _iComponentID,i32x _iState)
  248. {
  249.  
  250.     if(_iState & GUI_State_Checked)
  251.     {
  252.         SetContainerSprite(_iComponentID, 5, 0);
  253.     }
  254.     else
  255.     {
  256.         SetContainerSprite(_iComponentID, 4, 0);
  257.     }
  258.     if((_iState & GUI_State_UnderMouse)&&(GetContainerHelpIndex(_iComponentID)!=0))
  259.     {
  260.         if(ToolBar_GetHelpStringID() != GetContainerHelpIndex(_iComponentID))
  261.             Set_Tool_Bar_TextID(GetContainerHelpIndex(_iComponentID));
  262.         else
  263.             oToolBar.m_iCounter = oToolBar.m_iCounter + 1;
  264.     }
  265.     else
  266.     {
  267. //        if(ToolBar_GetHelpStringID() == GetContainerHelpIndex(_iComponentID))
  268.             Reset_Tool_Bar_Text();
  269.     }
  270. }
  271. func void ButtonSpeedState_4 (i32x _iComponentID,i32x _iState)
  272. {
  273.  
  274.     if(_iState & GUI_State_Checked)
  275.     {
  276.         SetContainerSprite(_iComponentID, 7, 0);
  277.     }
  278.     else
  279.     {
  280.         SetContainerSprite(_iComponentID, 6, 0);
  281.     }
  282.     if((_iState & GUI_State_UnderMouse)&&(GetContainerHelpIndex(_iComponentID)!=0))
  283.     {
  284.         if(ToolBar_GetHelpStringID() != GetContainerHelpIndex(_iComponentID))
  285.             Set_Tool_Bar_TextID(GetContainerHelpIndex(_iComponentID));
  286.         else
  287.             oToolBar.m_iCounter = oToolBar.m_iCounter + 1;
  288.     }
  289.     else
  290.     {
  291. //        if(ToolBar_GetHelpStringID() == GetContainerHelpIndex(_iComponentID))
  292.             Reset_Tool_Bar_Text();
  293.     }
  294. }
  295.  
  296. //----------------------------------------------------------------------------------------------------------------//
  297. // Update Race events list
  298. func void InRaceEvents_UpdateListDisplay ()
  299. {
  300.     var i32x i,iNumItems;
  301.     var component pOldParserComponent;
  302.     var frame fFrame1,fFrame2,fFrame3;
  303.     var szx szTemp;
  304.  
  305.     pOldParserComponent=GetParserComponent();
  306.     SetParserComponent(oRaceEvent.pThis);
  307.     i=0;
  308.     while(i<6)
  309.     {
  310.         //
  311.         if(oRaceEvent.m_cEvents[i] != ID_NOT_CREATED)
  312.         {
  313.             // Test animation state
  314.             if(GetAnimationState(oRaceEvent.m_cEvents[i])==false)
  315.             {
  316.                 // Animation ended
  317.                 oRaceEvent.m_cEventEnded[i] = true;
  318.             }
  319.         }
  320.         else
  321.         {
  322.             oRaceEvent.m_cEventEnded[i] = true;
  323.         }
  324.         i=i+1;
  325.     }
  326.  
  327.     if(oRaceEvent.m_iNeedUpdate)
  328.     {
  329.         var i32x bFound,iIndex,iEvent,iDistance,iNumCopy;
  330.  
  331.         // Update log windows (if any)
  332.         Panel_Inrace_EventLog_Update();
  333.  
  334.         iNumItems = Join_GetNumRows(oRaceEvent.m_jCyclistID)-oRaceEvent.m_iStartIndex;
  335.         bFound = false;
  336.  
  337.         if(iNumItems>0)
  338.         {
  339.             // Some events are waiting for announcement !
  340.  
  341.             i=5;
  342.             while(i>=0)
  343.             {
  344.                 // Find last free slot
  345.                 if(oRaceEvent.m_cEventEnded[i])
  346.                 {
  347.                     iIndex = i;
  348.                     bFound=true;
  349.                 }
  350.                 else
  351.                 {
  352.                     // Break loop
  353.                     i=0;
  354.                 }
  355.                 i=i-1;
  356.             }
  357.  
  358.             if(bFound)
  359.             {
  360.                 // ok
  361.                 if(oRaceEvent.m_cEvents[iIndex] == ID_NOT_CREATED)
  362.                 {
  363.                     // Create container
  364.                     // race name
  365.                     oRaceEvent.m_cEvents[iIndex]=InitContainer(tFnt_20);
  366.                     SetEvents(oRaceEvent.m_cEvents[iIndex],GUI_NoEvent);
  367.  
  368.                     //Parameters    :    Param(1-11) _ix,_iy,_fw,_fh,_fOffset,_fAngle,_r,_g,_b,_a,_fFrameOffset
  369.                     fFrame1 = AddFrame(oRaceEvent.m_cEvents[iIndex], 0, 64+32*iIndex, 1.0, 1.0, 0.0, 0.0, 255, 255, 255, 255, 0.0);
  370.                     fFrame2 = AddFrame(oRaceEvent.m_cEvents[iIndex], 0, 32+32*iIndex, 1.0, 1.0, 0.0, 0.0, 255, 255, 255, 250, 0.3);
  371.                     fFrame3 = AddFrame(oRaceEvent.m_cEvents[iIndex], 0, 0, 0.1, 0.1, 0.0, 0.0, 255, 255, 255, 0, 1.0);
  372.                     SetAnimationFlags(oRaceEvent.m_cEvents[iIndex],MSL_Color|MSL_Position|MSL_Scale);
  373.                     SetAnimationSpeed(oRaceEvent.m_cEvents[iIndex],0.005);
  374.                 }
  375.                 // Busy event
  376.                 oRaceEvent.m_cEventEnded[iIndex] = false;
  377.  
  378.                 // Get Evnt type
  379.                 iEvent = Join_GetIntFromIndex(oRaceEvent.m_jEventsType,oRaceEvent.m_iStartIndex);
  380.                 iDistance = Join_GetIntFromIndex(oRaceEvent.m_jEventsDistance,oRaceEvent.m_iStartIndex);
  381.                 iNumCopy = 0;
  382.                 if(((iEvent == InRaceServer_eEventAttack)||(iEvent == InRaceServer_eEventFall))&&(iNumItems>1))
  383.                 {
  384.                     while((iDistance == Join_GetIntFromIndex(oRaceEvent.m_jEventsDistance,oRaceEvent.m_iStartIndex+iNumCopy+1))&&
  385.                         (iEvent == Join_GetIntFromIndex(oRaceEvent.m_jEventsType,oRaceEvent.m_iStartIndex+iNumCopy+1))&&
  386.                         (iNumCopy+2<iNumItems))
  387.                     {
  388.                         iNumCopy = iNumCopy + 1;
  389.                     }
  390.                 }
  391.  
  392.                 if(iNumCopy>0)
  393.                 {
  394.                     if(iEvent == InRaceServer_eEventAttack)
  395.                     {
  396.                         szTemp = itoa(iDistance);
  397.                         szTemp = strcat(szTemp," ");
  398.                         szTemp = strcat(szTemp,GetLocalizedFromGMKey(306));
  399.                         szTemp = strcat(szTemp," ");
  400.                         szTemp = strcat(szTemp,itoa(iNumCopy+1));
  401.                         szTemp = strcat(szTemp," ");
  402.                         szTemp = strcat(szTemp,GetLocalizedFromGMKey(442));
  403.                     }
  404.                     else if(iEvent == InRaceServer_eEventFall)
  405.                     {
  406.                         szTemp = itoa(iDistance);
  407.                         szTemp = strcat(szTemp," ");
  408.                         szTemp = strcat(szTemp,GetLocalizedFromGMKey(307));
  409.                         szTemp = strcat(szTemp," ");
  410.                         szTemp = strcat(szTemp,itoa(iNumCopy+1));
  411.                         szTemp = strcat(szTemp," ");
  412.                         szTemp = strcat(szTemp,GetLocalizedFromGMKey(442));
  413.                     }
  414.                     SetContainerText(oRaceEvent.m_cEvents[iIndex],szTemp);
  415.                     //ResizeComponent(oInRaceEvents_List_Item.m_cEvents);
  416.                     // Start Animation !!!
  417.                     GotoFirstFrame(oRaceEvent.m_cEvents[iIndex]);
  418.                     StartAnimation(oRaceEvent.m_cEvents[iIndex]);
  419.                     oRaceEvent.m_iStartIndex = oRaceEvent.m_iStartIndex + 1 + iNumCopy;
  420.                 }
  421.                 else
  422.                 {
  423.                     // Retrieve race name
  424.                     szTemp=Join_GetStringFromIndex(oRaceEvent.m_jEventsString,oRaceEvent.m_iStartIndex);
  425.  
  426.                     SetContainerText(oRaceEvent.m_cEvents[iIndex],szTemp);
  427.                     //ResizeComponent(oInRaceEvents_List_Item.m_cEvents);
  428.                     // Start Animation !!!
  429.                     GotoFirstFrame(oRaceEvent.m_cEvents[iIndex]);
  430.                     StartAnimation(oRaceEvent.m_cEvents[iIndex]);
  431.  
  432.                     oRaceEvent.m_iStartIndex = oRaceEvent.m_iStartIndex + 1;
  433.                 }
  434.             }
  435.         }
  436.         else
  437.         {
  438.             // Wait for another event
  439.             oRaceEvent.m_iNeedUpdate = false;
  440.         }
  441.  
  442.     }
  443.     // restore old parser component
  444.     SetParserComponent(pOldParserComponent);
  445. }
  446.  
  447.  
  448. func void UpdateEventDatabase(i32x _iEventType,i32x _iPreRaceCyclistIndex,szx _szEvnt,i32x _iKm)
  449. {
  450.     if((_iEventType == InRaceServer_eEventAttack)||(_iEventType == InRaceServer_eEventWithdrawal)
  451.         ||(_iEventType == InRaceServer_eEventSprint)||(_iEventType == InRaceServer_eEventFall)||
  452.         (_iEventType == InRaceServer_eEventRetained))
  453.     {
  454.         var i32x iRowIndex;
  455.         //Add the new event to the database
  456.         iRowIndex = Table_AddRow(DB_INRACE_EVENTS,TABLE_INRACE_EVENTS);
  457.         Join_SetIntFromIndex(    oRaceEvent.m_jCyclistID,    iRowIndex,    _iPreRaceCyclistIndex);
  458.         Join_SetIntFromIndex(oRaceEvent.m_jEventsType,iRowIndex,_iEventType);
  459.         Join_SetIntFromIndex(oRaceEvent.m_jEventsDistance,iRowIndex,_iKm);
  460.         
  461.         Join_SetStringFromIndex(oRaceEvent.m_jEventsString,    iRowIndex,    _szEvnt);
  462.         Database_Update(DB_INRACE_EVENTS);
  463.         oRaceEvent.m_iNeedUpdate=true;
  464.     }
  465. }
  466.  
  467.  
  468.  
  469. //----------------------------------------------------------------------------------------------------------------//
  470. //----------------------------------------------------------------------------------------------------------------//
  471. //Send Event func function called from the menuserver 
  472. //----------------------------------------------------------------------------------------------------------------//
  473. //----------------------------------------------------------------------------------------------------------------//
  474. func void SendEvent_Null(i32x _iEventType,i32x _iPreRaceCyclistIndex,i32x _iParam1,i32x _iParam2,szx _szParam)
  475. {
  476. }
  477.  
  478. func i32x IsSomeBodyArrived()
  479. {
  480.     if(GetNbGroups()>0)
  481.     {
  482.         if(GetCyclistRacePercentageDone(GetFirstCyclistPreRaceIndexFromGroup(0))>=99.5)
  483.         {
  484.             return 1;
  485.         }
  486.         else
  487.         {
  488.             return 0;
  489.         }
  490.     }
  491.     return 0;
  492. }
  493.  
  494.  
  495. func void SendEvent(i32x _iEventType,i32x _iPreRaceCyclistIndex,i32x _iParam1,i32x _iParam2,szx _szParam)
  496. {
  497.     var i32x iDistance,iRows;
  498.     var szx szEvnt;
  499.     
  500.     //Get position of the cyclist: *10 to get real distance
  501.     iDistance = (GetCyclistSplinePosition(_iPreRaceCyclistIndex)*0.01);
  502.     
  503.     if(_iEventType == InRaceServer_eEventAccel)
  504.     {}
  505.     else if(_iEventType == InRaceServer_eEventAttack)
  506.     {
  507.         /*
  508.         print("GetEvent Attack from cyclist:");
  509.         print(itoa(_iPreRaceCyclistIndex));
  510.         print("\n");
  511.         */
  512.         
  513.         //remove all send event attack at the end of the race
  514.         if(!(IsSomeBodyArrived()))
  515.         {
  516.             szEvnt = itoa(iDistance);
  517.             szEvnt = strcat(szEvnt," ");
  518.             szEvnt = strcat(szEvnt,GetLocalizedFromGMKey(306));
  519.             szEvnt = strcat(szEvnt," ");
  520.             szEvnt = strcat(szEvnt,Join_GetStringFromSortedIndex(g_stInraceJoins.m_iCyclist_FirstName,_iPreRaceCyclistIndex));
  521.             szEvnt = strcat(szEvnt," ");
  522.             szEvnt = strcat(szEvnt,Join_GetStringFromSortedIndex(g_stInraceJoins.m_iCyclist_LastName,_iPreRaceCyclistIndex));
  523.             UpdateEventDatabase(_iEventType,_iPreRaceCyclistIndex,szEvnt,iDistance);
  524.         }
  525.     }
  526.     else if(_iEventType == InRaceServer_eEventFall)
  527.     {
  528.         /*
  529.         print("GetEvent fall from cyclist:");
  530.         print(itoa(_iPreRaceCyclistIndex));
  531.         print("\n");
  532.         */
  533.  
  534.         PlaySound(1,sbCyclistsSound[0]);
  535.                 
  536.         szEvnt = itoa(iDistance);
  537.         szEvnt = strcat(szEvnt," ");
  538.         szEvnt = strcat(szEvnt,GetLocalizedFromGMKey(307));
  539.         szEvnt = strcat(szEvnt," ");
  540.         szEvnt = strcat(szEvnt,Join_GetStringFromSortedIndex(g_stInraceJoins.m_iCyclist_FirstName,_iPreRaceCyclistIndex));
  541.         szEvnt = strcat(szEvnt," ");
  542.         szEvnt = strcat(szEvnt,Join_GetStringFromSortedIndex(g_stInraceJoins.m_iCyclist_LastName,_iPreRaceCyclistIndex));
  543.         UpdateEventDatabase(_iEventType,_iPreRaceCyclistIndex,szEvnt,iDistance);
  544.     }
  545.     else if(_iEventType == InRaceServer_eEventFlat)
  546.     {}
  547.     else if(_iEventType == InRaceServer_eEventHWound)
  548.     {}
  549.     else if(_iEventType == InRaceServer_eEventLWound)
  550.     {}
  551.     else if(_iEventType == InRaceServer_eEventSprint)
  552.     {
  553.     /*
  554.         println("GetEvent Sprint from cyclist:");
  555.         print(itoa(_iPreRaceCyclistIndex));
  556.         print("\t time=");
  557.         println(itoa(_iParam2));
  558.         */
  559.                 
  560.         RegisterSprintCyclist(_iParam1&255,_iPreRaceCyclistIndex,_iParam2);
  561.         
  562.         if (GetInRaceMode()==G_iRaceModeTimeTrial)
  563.         {
  564.             //mise α jour de la liste
  565.             Sprint_List_NeedUpdate();
  566.             
  567.         }
  568.         
  569.         if (GetInRaceMode()==G_iRaceModeTeamTimeTrial)
  570.         {
  571.             var f32x fCyclistTime;
  572.             var i32x iNumSprint,iTeamID,boucle,boucle2;
  573.             
  574.             
  575.             iNumSprint=_iParam1&255;
  576.             iTeamID=GetCyclistPreRaceTeamID(_iPreRaceCyclistIndex);
  577.  
  578.  
  579.             fCyclistTime=GetSprintCyclistTimeFromPreRaceID(iNumSprint,_iPreRaceCyclistIndex);
  580.             oRace.Tab_Team_Sprints[iNumSprint].Tab[iTeamID].iNbCyclistsRecorded=oRace.Tab_Team_Sprints[iNumSprint].Tab[iTeamID].iNbCyclistsRecorded+1;
  581.             // si cinquieme cycliste, enregistrement du temps
  582.             if (oRace.Tab_Team_Sprints[iNumSprint].Tab[iTeamID].iNbCyclistsRecorded==5)
  583.             {
  584.                 oRace.Tab_Team_Sprints[iNumSprint].Tab[iTeamID].fSprintTime=fCyclistTime;
  585.                 oRace.Tab_Team_Sprints[iNumSprint].Tab[iTeamID].iCyclistID=_iPreRaceCyclistIndex;
  586.  
  587.             /*    print("cinquieme cycliste:");
  588.                 print(Join_GetStringFromSortedIndex(g_stInraceJoins.m_iCyclist_LastName,_iPreRaceCyclistIndex));
  589.                 print(" temps: ");
  590.                 print(itoa(iCyclistTime));
  591.                 print("\n");*/
  592.                 oRace.TabSprintClassement[iNumSprint].iNbTeamRecorded=oRace.TabSprintClassement[iNumSprint].iNbTeamRecorded+1;
  593.                 boucle=0;
  594.             /*    print("nbre de teams enregistrΘes: ");
  595.                 print(itoa(oRace.TabSprintClassement[iNumSprint].iNbTeamRecorded));
  596.                 print("\n");*/
  597.  
  598.                 //recherche
  599.                 while(boucle<oRace.TabSprintClassement[iNumSprint].iNbTeamRecorded-1
  600.                     && fCyclistTime>oRace.Tab_Team_Sprints[iNumSprint].Tab[oRace.TabSprintClassement[iNumSprint].TabSprintClassement[boucle].iTeamID].fSprintTime)
  601.                     boucle=boucle+1;
  602.                 boucle2=oRace.TabSprintClassement[iNumSprint].iNbTeamRecorded-1;
  603.                 
  604.                 //decalage
  605.                 while (boucle2>boucle)
  606.                 {
  607.                     oRace.TabSprintClassement[iNumSprint].TabSprintClassement[boucle2].iTeamID=oRace.TabSprintClassement[iNumSprint].TabSprintClassement[boucle2-1].iTeamID;
  608.                     boucle2=boucle2-1;
  609.                 }
  610.  
  611.                 //insertion
  612.                 oRace.TabSprintClassement[iNumSprint].TabSprintClassement[boucle].iTeamID=iTeamID;
  613.                 
  614.                 
  615.             }
  616.             
  617.             Sprint_List_NeedUpdate();
  618.         }
  619.         
  620.         if((_iParam1&255)==(GetNbSprints()-1))
  621.         {
  622.             //the race is finished for this cyclist so desactivate his control panel
  623.             if(GetCyclistPreRaceTeamID(_iPreRaceCyclistIndex)==g_oUser.m_iMyInRaceTeamID)
  624.             {
  625.                 DesactivateControlPanel(GetCyclistPreRaceLocalID(_iPreRaceCyclistIndex));
  626.             }
  627.         }
  628.  
  629.         if (GetInRaceMode()==G_iRaceModeNormal)
  630.         {
  631.             if(GetSprintNumRecordedCyclists(_iParam1&255)<=3)
  632.             {
  633.                 if((_iParam1&255)<Join_GetNumRows(g_stInraceJoins.m_iSprint_Name))
  634.                 {
  635.                     szEvnt = Join_GetStringFromSortedIndex(g_stInraceJoins.m_iSprint_Name,(_iParam1&255));
  636.                 }
  637.                 else
  638.                 {
  639. // MistER-j WARNING LOCALIZED
  640.                     szEvnt="Default sprint";
  641.                 }
  642.                 
  643.                 szEvnt = strcat(szEvnt," : ");
  644.                 szEvnt = strcat(szEvnt,Join_GetStringFromSortedIndex(g_stInraceJoins.m_iCyclist_FirstName,_iPreRaceCyclistIndex));
  645.                 szEvnt = strcat(szEvnt," ");
  646.                 szEvnt = strcat(szEvnt,Join_GetStringFromSortedIndex(g_stInraceJoins.m_iCyclist_LastName,_iPreRaceCyclistIndex));
  647.                 
  648.                 UpdateEventDatabase(_iEventType,_iPreRaceCyclistIndex,szEvnt,0);
  649.                 
  650.                 //debug vincent
  651.                 /*    print("\n nbre de cyclistes enregistres α ce sprint:");
  652.                 var i32x inbcyclists;
  653.                 inbcyclists=GetSprintNumRecordedCyclists(_iParam1&255);
  654.                 print(itoa(inbcyclists));
  655.                 print("\n");
  656.                 print("temps  :");
  657.  
  658.                 print(ftoa(GetSprintCyclistTime(_iParam1&255,inbcyclists-1)));
  659.                 print("\n");
  660.                 
  661.                 print("\n Nb sprints in race: ");
  662.                 print(itoa(GetNbSprints()));
  663.                 print("\n");*/
  664.             }//end of if GetSprintNumRecordedCyclists(_iParam1&255)<=3
  665.         }//end of if racemode = normal
  666.         RefreshInfos();
  667.     }
  668.     else if(_iEventType == InRaceServer_eEventWithdrawal)
  669.     {
  670.         /*
  671.         print("\nGetEvent Withdrawal from cyclist:");
  672.         print(itoa(_iPreRaceCyclistIndex));
  673.         print("\n");
  674.         */
  675.         
  676.         // Leave event
  677.         szEvnt = itoa(iDistance);
  678.         szEvnt = strcat(szEvnt," ");
  679.         szEvnt = strcat(szEvnt,GetLocalizedFromGMKey(309));
  680.         szEvnt = strcat(szEvnt," ");
  681.         szEvnt = strcat(szEvnt,Join_GetStringFromSortedIndex(g_stInraceJoins.m_iCyclist_FirstName,_iPreRaceCyclistIndex));
  682.         szEvnt = strcat(szEvnt," ");
  683.         szEvnt = strcat(szEvnt,Join_GetStringFromSortedIndex(g_stInraceJoins.m_iCyclist_LastName,_iPreRaceCyclistIndex));
  684.         UpdateEventDatabase(_iEventType,_iPreRaceCyclistIndex,szEvnt,iDistance);
  685.         
  686.         if(GetCyclistPreRaceTeamID(_iPreRaceCyclistIndex)==g_oUser.m_iMyInRaceTeamID)
  687.         {
  688.             DesactivateControlPanel(GetCyclistPreRaceLocalID(_iPreRaceCyclistIndex));
  689.         }
  690.     }
  691.     else if(_iEventType == InRaceServer_eEventRetained)
  692.     {
  693.     /*
  694.     print("\nGetEvent Retained Cyclist:");
  695.     print(itoa(_iPreRaceCyclistIndex));
  696.     print("\n");
  697.         */
  698.         if(GetCyclistPreRaceTeamID(_iPreRaceCyclistIndex)==g_oUser.m_iMyInRaceTeamID)
  699.         {
  700.             // Leave event
  701.             szEvnt = itoa(iDistance);
  702.             szEvnt = strcat(szEvnt," km : ");
  703.             szEvnt = strcat(szEvnt,Join_GetStringFromSortedIndex(g_stInraceJoins.m_iCyclist_FirstName,_iPreRaceCyclistIndex));
  704.             szEvnt = strcat(szEvnt," ");
  705.             szEvnt = strcat(szEvnt,Join_GetStringFromSortedIndex(g_stInraceJoins.m_iCyclist_LastName,_iPreRaceCyclistIndex));
  706.             szEvnt = strcat(szEvnt," ");
  707.             szEvnt = strcat(szEvnt,GetLocalizedFromGMKey(384));
  708.             UpdateEventDatabase(_iEventType,_iPreRaceCyclistIndex,szEvnt,iDistance);
  709.         }
  710.     }
  711.     else if(_iEventType == InRaceServer_eEventStartRaceSprint)
  712.     {
  713.         //print("\n Receive start cyclist time.");
  714.         SetStartRaceCyclistTime(_iPreRaceCyclistIndex,(1.0*(_iParam1))/65536.0);
  715.         
  716.         if(GetCyclistPreRaceTeamID(_iPreRaceCyclistIndex)==g_oUser.m_iMyInRaceTeamID)
  717.         {
  718.             ActivateControlPanel(GetCyclistPreRaceLocalID(_iPreRaceCyclistIndex));
  719.         }
  720.     }
  721. }
  722.  
  723.  
  724.  
  725. func void vRaceSetProfileZoom(i32x _iZoomIndex)
  726. {
  727.     //print("*** vRaceSetProfileZoom\n");
  728.     
  729.     if ((_iZoomIndex>=0)&&(_iZoomIndex<=oProfileCamera.m_iZoomIndexMax)&&(_iZoomIndex!=oProfileCamera.m_iZoomIndex))
  730.     {
  731.         vSetProfileCameraZoom(_iZoomIndex);
  732.     }
  733.     oRace.bNeedRefreshProfileZoom=1;
  734. }
  735.  
  736.  
  737. //----------------------------------------------------------------------------------------------------------------//
  738. //----------------------------------------------------------------------------------------------------------------//
  739. //RaceEvent Create func
  740. //----------------------------------------------------------------------------------------------------------------//
  741. //----------------------------------------------------------------------------------------------------------------//
  742. func void RaceEvent_Create ()
  743. {
  744.     var i32x i;
  745.     oRaceEvent.pThis = GetParserComponent();
  746.     
  747.     SetComponentNumber(16);
  748. }
  749.  
  750. //----------------------------------------------------------------------------------------------------------------//
  751. //----------------------------------------------------------------------------------------------------------------//
  752. //TeamPanel Event func
  753. //----------------------------------------------------------------------------------------------------------------//
  754. //----------------------------------------------------------------------------------------------------------------//
  755. func i32x RaceEvent_Event (i32x _iComponentID,i32x _iEvent)
  756. {
  757.     return 1;
  758. }
  759.  
  760. //----------------------------------------------------------------------------------------------------------------//
  761. //----------------------------------------------------------------------------------------------------------------//
  762. //TeamPanel Init func
  763. //----------------------------------------------------------------------------------------------------------------//
  764. //----------------------------------------------------------------------------------------------------------------//
  765. func void RaceEvent_Init ()
  766. {
  767.     var i32x i;
  768.     i=0;
  769.     while(i<6)
  770.     {
  771.         oRaceEvent.m_cEvents[i] = ID_NOT_CREATED;
  772.         oRaceEvent.m_cEventEnded[i] = true;
  773.         i=i+1;
  774.     }
  775.     oRaceEvent.m_iStartIndex = 0;
  776.     oRaceEvent.oFunc.pcreate = RaceEvent_Create;
  777.     oRaceEvent.oFunc.pevent = RaceEvent_Event;
  778. }
  779.  
  780. // ***********************************
  781. // Chat
  782. // ***********************************
  783. //----------------------------------------------------------------------------------------------------------------//
  784. // Update Race chat 
  785. func void InRaceChat_UpdateDisplay ()
  786. {
  787.     var i32x i,iNumItems;
  788.     var component pOldParserComponent;
  789.     var frame fFrame1,fFrame2,fFrame3;
  790.     var szx szTemp;
  791.  
  792.     pOldParserComponent=GetParserComponent();
  793.     SetParserComponent(oRaceChat.pThis);
  794.     i=0;
  795.     while(i<3)
  796.     {
  797.         //
  798.         if(oRaceChat.m_cEvents[i] != ID_NOT_CREATED)
  799.         {
  800.             // Test animation state
  801.             if(GetAnimationState(oRaceChat.m_cEvents[i])==false)
  802.             {
  803.                 // Animation ended
  804.                 oRaceChat.m_cEventEnded[i] = true;
  805.             }
  806.         }
  807.         else
  808.         {
  809.             oRaceChat.m_cEventEnded[i] = true;
  810.         }
  811.         i=i+1;
  812.     }
  813.  
  814.     if(oRaceChat.m_iNeedUpdate)
  815.     {
  816.         var i32x bFound,iIndex;
  817.  
  818.         iNumItems = (oPanelInraceChat.iCursor - oRaceChat.m_iStartIndex);
  819.         if(iNumItems<0)
  820.             iNumItems = iNumItems + oPanelInraceChat.iMaxListItems;
  821.  
  822.         bFound = false;
  823.  
  824.         if(iNumItems>0)
  825.         {
  826.             // Some msg are waiting for announcement !
  827.  
  828.             i=2;
  829.             while(i>=0)
  830.             {
  831.                 // Find last free slot
  832.                 if(oRaceChat.m_cEventEnded[i])
  833.                 {
  834.                     iIndex = i;
  835.                     bFound=true;
  836.                 }
  837.                 else
  838.                 {
  839.                     // Break loop
  840.                     i=0;
  841.                 }
  842.                 i=i-1;
  843.             }
  844.  
  845.             if(bFound)
  846.             {
  847.                 // ok
  848.                 if(oRaceChat.m_cEvents[iIndex] == ID_NOT_CREATED)
  849.                 {
  850.                     // Create container
  851.                     // race name
  852.                     oRaceChat.m_cEvents[iIndex]=InitContainer(tFontArialItalique);
  853.                     SetEvents(oRaceChat.m_cEvents[iIndex],GUI_NoEvent);
  854.  
  855.                     //Parameters    :    Param(1-11) _ix,_iy,_fw,_fh,_fOffset,_fAngle,_r,_g,_b,_a,_fFrameOffset
  856.                     fFrame1 = AddFrame(oRaceChat.m_cEvents[iIndex], 0, 29*iIndex, 1.0, 1.0, 0.0, 0.0, 255, 255, 255, 255, 0.0);
  857.                     fFrame2 = AddFrame(oRaceChat.m_cEvents[iIndex], 0, 29*iIndex, 1.0, 1.0, 0.0, 0.0, 255, 255, 255, 255, 0.9);
  858.                     fFrame3 = AddFrame(oRaceChat.m_cEvents[iIndex], 0, 29*iIndex, 1.0, 1.0, 0.0, 0.0, 255, 255, 255, 0, 1.0);
  859.                     SetAnimationFlags(oRaceChat.m_cEvents[iIndex],MSL_Color|MSL_Position);
  860.                 }
  861.                 // Busy event
  862.                 oRaceChat.m_cEventEnded[iIndex] = false;
  863.  
  864.                 // Retrieve msg
  865.                 szTemp = oPanelInraceChat.szChatTab[oRaceChat.m_iStartIndex];
  866.  
  867.                 SetContainerText(oRaceChat.m_cEvents[iIndex],szTemp);
  868.                 //ResizeComponent(oInRaceEvents_List_Item.m_cEvents);
  869.                 // Start Animation !!!
  870.                 if(iNumItems>12)
  871.                 {
  872.                     SetAnimationSpeed(oRaceChat.m_cEvents[iIndex],0.018);
  873.                 }
  874.                 else if(iNumItems>6)
  875.                 {
  876.                     SetAnimationSpeed(oRaceChat.m_cEvents[iIndex],0.0012);
  877.                 }
  878.                 else if(iNumItems>3)
  879.                 {
  880.                     SetAnimationSpeed(oRaceChat.m_cEvents[iIndex],0.006);
  881.                 }
  882.                 else
  883.                 {
  884.                     SetAnimationSpeed(oRaceChat.m_cEvents[iIndex],0.003);
  885.                 }
  886.                 GotoFirstFrame(oRaceChat.m_cEvents[iIndex]);
  887.                 StartAnimation(oRaceChat.m_cEvents[iIndex]);
  888.  
  889.                 oRaceChat.m_iStartIndex = oRaceChat.m_iStartIndex + 1;
  890.                 oRaceChat.m_iStartIndex = oRaceChat.m_iStartIndex%oPanelInraceChat.iMaxListItems;
  891.             }
  892.         }
  893.         else
  894.         {
  895.             // Wait for another event
  896.             oRaceChat.m_iNeedUpdate = false;
  897.         }
  898.  
  899.     }
  900.     // restore old parser component
  901.     SetParserComponent(pOldParserComponent);
  902. }
  903.  
  904. //----------------------------------------------------------------------------------------------------------------//
  905. //----------------------------------------------------------------------------------------------------------------//
  906. //RaceEvent Create func
  907. //----------------------------------------------------------------------------------------------------------------//
  908. //----------------------------------------------------------------------------------------------------------------//
  909. func void RaceChat_Create ()
  910. {
  911.     oRaceChat.pThis = GetParserComponent();
  912.     
  913.     SetComponentNumber(3);
  914. }
  915.  
  916. //----------------------------------------------------------------------------------------------------------------//
  917. //----------------------------------------------------------------------------------------------------------------//
  918. //Chat Event func
  919. //----------------------------------------------------------------------------------------------------------------//
  920. //----------------------------------------------------------------------------------------------------------------//
  921. func i32x RaceChat_Event (i32x _iComponentID,i32x _iEvent)
  922. {
  923.     return 1;
  924. }
  925.  
  926. //----------------------------------------------------------------------------------------------------------------//
  927. //----------------------------------------------------------------------------------------------------------------//
  928. //Chat Init func
  929. //----------------------------------------------------------------------------------------------------------------//
  930. //----------------------------------------------------------------------------------------------------------------//
  931. func void RaceChat_Init ()
  932. {
  933.     var i32x i;
  934.     i=0;
  935.     while(i<3)
  936.     {
  937.         oRaceChat.m_cEvents[i] = ID_NOT_CREATED;
  938.         oRaceChat.m_cEventEnded[i] = true;
  939.         i=i+1;
  940.     }
  941.     oRaceChat.m_iStartIndex = 0;
  942.     oRaceChat.oFunc.pcreate = RaceChat_Create;
  943.     oRaceChat.oFunc.pevent = RaceChat_Event;
  944. }
  945. //----------------------------------------------------------------------------------------------------------------//
  946. //----------------------------------------------------------------------------------------------------------------//
  947. //Race Window Create func
  948. //----------------------------------------------------------------------------------------------------------------//
  949. //----------------------------------------------------------------------------------------------------------------//
  950.  
  951. // Groups Update Callback func
  952. func void UpdateGroups()
  953. {
  954.     var component pCurrentContext;
  955.     pCurrentContext=GetParserComponent();
  956.     SetParserComponent(oGroups.pGroups);
  957.     
  958.     if (GetInRaceMode()==G_iRaceModeNormal)
  959.         Groups_Update();
  960.     else if (GetInRaceMode()==G_iRaceModeTimeTrial)
  961.     {
  962.         Groups_Time_Trial_Update();
  963.         //Object_InRaceEvents_Time_Trial_Update();
  964.     }
  965.     else
  966.     {
  967.         Groups_Team_Time_Trial_Update();    
  968.         //Object_InRaceEvents_Team_Time_Trial_Update();
  969.     }
  970.     
  971.     SetParserComponent(pCurrentContext);
  972.     
  973.     // Update blue panel
  974.     Panel_Inrace_Tab_Update ();
  975. }
  976.  
  977. func void UpdateGroupsPositions()
  978. {
  979.     var component pCurrentContext;
  980.     pCurrentContext=GetParserComponent();
  981.     SetParserComponent(oGroups.pGroups);
  982.  
  983.     if (GetInRaceMode()==G_iRaceModeNormal)
  984.         Groups_UpdatePosition();
  985.     else if (GetInRaceMode()==G_iRaceModeTimeTrial)
  986.     {
  987.         Object_InRaceEvents_Time_Trial_Update();
  988.         Groups_Time_Trial_UpdatePosition();
  989.         
  990.     }
  991.     else
  992.     {
  993.         Groups_Team_Time_Trial_UpdatePosition();
  994.         Object_InRaceEvents_Team_Time_Trial_Update();
  995.         Panel_Cyclist_Team_Time_Trial_Update();
  996.     }
  997.  
  998.     SetParserComponent(pCurrentContext);
  999. }
  1000.  
  1001. func void UpdateSprintsPositions()
  1002. {
  1003.     var component pCurrentContext;
  1004.     pCurrentContext=GetParserComponent();
  1005.     
  1006.     SetParserComponent(oPanel_Team_Tactic_Profil.cComponent);
  1007.  
  1008.     if(Geti32x(oPanel_Team_Tactic_Profil.m_iWithSprints))
  1009.     {
  1010.         var i32x iTemp,iNumSprints,iPosX;
  1011.         var f32x fPercentage;
  1012.  
  1013.         //iNumSprints=Spline_GetNumSprints(Spline_GetSplinePointer(Geti32x(oPanel_Team_Tactic_Profil.m_ipoSimpleSpline)));
  1014.         iNumSprints=Join_GetIntFromKey(g_oMenuJoins.m_iStage_iNumSprints,  oPanel_Team_Tactic_Profil.iStageId);
  1015.  
  1016.         iTemp=0;
  1017.         while(iTemp<iNumSprints)
  1018.         {
  1019.             fPercentage = 
  1020.                 Join_GetFloatFromSortedIndex(    g_oMenuJoins.m_iSprint_fPosition, oPanel_Team_Tactic_Profil.iFirstSprint+iTemp) /
  1021.                 Join_GetFloatFromKey(            g_oMenuJoins.m_iStage_fSplineLength, oPanel_Team_Tactic_Profil.iStageId);
  1022.  
  1023.             iPosX = (iGetProfileCameraXPixelPosFromSplinePercentageDone(100.0*fPercentage)+oProfileCamera.m_iWindowPosX-1)-(GetComponentWidth(oPanel_Team_Tactic_Profil.a16_iSprintID[iTemp])/2);
  1024.             SetComponentPositionX(oPanel_Team_Tactic_Profil.a16_iSprintID[iTemp], iPosX);
  1025.             SetComponentPositionX(oPanel_Team_Tactic_Profil.a16_iSprintCursorID[iTemp], iPosX);
  1026.             iTemp=iTemp+1;
  1027.         }
  1028.     }
  1029.  
  1030.     SetParserComponent(pCurrentContext);
  1031. }
  1032.  
  1033.  
  1034. //----------------------------------------------------------------------------------------------------------------//
  1035. //----------------------------------------------------------------------------------------------------------------//
  1036. //Follow camera loop func
  1037. //----------------------------------------------------------------------------------------------------------------//
  1038. //----------------------------------------------------------------------------------------------------------------//
  1039. func void FollowCamera()
  1040. {
  1041.     var boolx bDrawCameraTarget;
  1042.     
  1043.     bDrawCameraTarget=0;
  1044.  
  1045.     // debug : special demo
  1046.     if(G_iDebugVersion)
  1047.     {
  1048.         if ((GetKeyState(DIK_RCONTROL))&&(GetKeyState(DIK_RSHIFT)))
  1049.         {
  1050.             var f32x fDelta;
  1051.             
  1052.             fDelta=0.0;
  1053.             if(GetKeyState(DIK_UP)) fDelta=fDelta-FOV_STEP;
  1054.             if(GetKeyState(DIK_DOWN)) fDelta=fDelta+FOV_STEP;
  1055.             if(fDelta!=0.0)
  1056.             {
  1057.                 CameraOffsetFOV(fDelta);
  1058.             }
  1059.             
  1060.             fDelta=0.0;
  1061.             if(GetKeyState(DIK_LEFT)) fDelta=fDelta-CATCH_UP_STEP;
  1062.             if(GetKeyState(DIK_RIGHT)) fDelta=fDelta+CATCH_UP_STEP;
  1063.             if(fDelta!=0.0)
  1064.             {
  1065.                 CameraOffsetCatchUpTime(fDelta);
  1066.             }
  1067.             
  1068.             bDrawCameraTarget=1;
  1069.         }
  1070.         else if (GetKeyState(DIK_RSHIFT))
  1071.         {
  1072.             if(GetKeyState(DIK_UP)) 
  1073.                 CameraOffsetPosition(0.0,OFFSET_STEP,0.0);
  1074.             if(GetKeyState(DIK_DOWN))
  1075.                 CameraOffsetPosition(0.0,-OFFSET_STEP,0.0);
  1076.             if(GetKeyState(DIK_RIGHT))
  1077.                 CameraOffsetPosition(OFFSET_STEP,0.0,0.0);
  1078.             if(GetKeyState(DIK_LEFT))
  1079.                 CameraOffsetPosition(-OFFSET_STEP,0.0,0.0);
  1080.             if(GetKeyState(DIK_PGUP))
  1081.                 CameraOffsetPosition(0.0,0.0,OFFSET_STEP);
  1082.             if(GetKeyState(DIK_PGDN))
  1083.                 CameraOffsetPosition(0.0,0.0,-OFFSET_STEP);
  1084.             
  1085.             bDrawCameraTarget=1;
  1086.         }
  1087.         else if (GetKeyState(DIK_RCONTROL))
  1088.         {
  1089.             if(GetKeyState(DIK_UP))
  1090.             { 
  1091.                 CameraRoll(1.0*TURN_STEP);
  1092.                 bDrawCameraTarget=1;
  1093.             }
  1094.             if(GetKeyState(DIK_DOWN))
  1095.             {
  1096.                 CameraRoll(-1.0*TURN_STEP);
  1097.                 bDrawCameraTarget=1;
  1098.             }
  1099.             if(GetKeyState(DIK_RIGHT))
  1100.             {
  1101.                 CameraTurn(1.0*TURN_STEP);
  1102.                 bDrawCameraTarget=1;
  1103.             }
  1104.             if(GetKeyState(DIK_LEFT))
  1105.             {
  1106.                 CameraTurn(-1.0*TURN_STEP);
  1107.                 bDrawCameraTarget=1;
  1108.             }
  1109.             if(GetKeyState(DIK_PGUP))
  1110.             {
  1111.                 CameraStrafeUpDown(-2.0*OFFSET_STEP);
  1112.                 bDrawCameraTarget=1;
  1113.             }
  1114.             if(GetKeyState(DIK_PGDN))
  1115.             {
  1116.                 CameraStrafeUpDown(2.0*OFFSET_STEP);
  1117.                 bDrawCameraTarget=1;
  1118.             }
  1119.             
  1120.             //if (GetMouseTrueRelX()!=0) CameraTurn(0.3*TURN_STEP * GetMouseTrueRelX());
  1121.             //if (GetMouseTrueRelY()!=0) CameraRoll(0.3*TURN_STEP * GetMouseTrueRelY());
  1122.         }
  1123.         
  1124.         if (oRace.bDrawCameraTarget!=bDrawCameraTarget)
  1125.         {
  1126.             oRace.bDrawCameraTarget=bDrawCameraTarget;
  1127.             CameraDrawTarget(bDrawCameraTarget);
  1128.         }
  1129.     }// debug : if special demo
  1130. }
  1131.  
  1132.  
  1133. //----------------------------------------------------------------------------------------------------------------//
  1134. //----------------------------------------------------------------------------------------------------------------//
  1135. //Follow cyclist camera loop func
  1136. //----------------------------------------------------------------------------------------------------------------//
  1137. //----------------------------------------------------------------------------------------------------------------//
  1138. func void FollowCyclistCamera()
  1139. {
  1140.     FollowCamera();
  1141. }
  1142.  
  1143. //----------------------------------------------------------------------------------------------------------------//
  1144. //----------------------------------------------------------------------------------------------------------------//
  1145. //Path camera loop func
  1146. //----------------------------------------------------------------------------------------------------------------//
  1147. //----------------------------------------------------------------------------------------------------------------//
  1148. func void ManPathCamera()
  1149. {
  1150.     FollowCamera();
  1151.     
  1152.     if ((!(GetKeyState(DIK_RCONTROL)))&&(!(GetKeyState(DIK_RSHIFT))))
  1153.     {
  1154.         if (GetKeyState(DIK_NUMPAD0))
  1155.         {
  1156.             if(GetKeyState(DIK_RIGHT))
  1157.                 CameraStrafeRightLeft(20.0*STRAFE_STEP);
  1158.             if(GetKeyState(DIK_LEFT))
  1159.                 CameraStrafeRightLeft(-20.0*STRAFE_STEP);
  1160.         }
  1161.         else
  1162.         {
  1163.             if(GetKeyState(DIK_RIGHT))
  1164.                 CameraStrafeRightLeft(STRAFE_STEP);
  1165.             if(GetKeyState(DIK_LEFT))
  1166.                 CameraStrafeRightLeft(-STRAFE_STEP);
  1167.         }
  1168.     }
  1169. }
  1170.  
  1171. //----------------------------------------------------------------------------------------------------------------//
  1172. //----------------------------------------------------------------------------------------------------------------//
  1173. //Doom like camera loop func
  1174. //----------------------------------------------------------------------------------------------------------------//
  1175. //----------------------------------------------------------------------------------------------------------------//
  1176. func void DoomCamera()
  1177. {
  1178.     CameraTurn(TURN_STEP * GetMouseTrueRelX());
  1179.     CameraRoll(TURN_STEP * GetMouseTrueRelY());
  1180.     
  1181.     if(GetKeyState(DIK_UP))
  1182.         CameraStrafeFrontBack(STRAFE_STEP);
  1183.     if(GetKeyState(DIK_DOWN))
  1184.         CameraStrafeFrontBack(-STRAFE_STEP);
  1185.     if(GetKeyState(DIK_RIGHT))
  1186.         CameraStrafeRightLeft(STRAFE_STEP);
  1187.     if(GetKeyState(DIK_LEFT))
  1188.         CameraStrafeRightLeft(-STRAFE_STEP);
  1189.     if(GetKeyState(DIK_PGUP))
  1190.         CameraStrafeUpDown(STRAFE_STEP);
  1191.     if(GetKeyState(DIK_PGDN))
  1192.         CameraStrafeUpDown(-STRAFE_STEP);
  1193. }
  1194.  
  1195. func void RefreshAIDrawInfos()
  1196. {
  1197.     SetContainerText(oRace.iInfoIAID, GetActiveCyclistAIState());
  1198. }
  1199.  
  1200. func void RefreshPictoVent()
  1201. {
  1202.     var szx szWindText;
  1203.     var i32x iWindValue;
  1204.  
  1205.     iWindValue = 3.6*GetWindSpeed();
  1206.     szWindText = strcat(itoa(iWindValue),"km/h");
  1207.     SetContainerText(oRace.iWindTextID,szWindText);
  1208.  
  1209.     if(iWindValue<=1)
  1210.         SetContainerSprite(oRace.iWindIconID,0,0);
  1211.     else if(iWindValue<4)
  1212.         SetContainerSprite(oRace.iWindIconID,1,0);
  1213.     else if(iWindValue<12)
  1214.         SetContainerSprite(oRace.iWindIconID,2,0);
  1215.     else
  1216.         SetContainerSprite(oRace.iWindIconID,3,0);
  1217. }
  1218. func void RefreshPictoAngle()
  1219. {
  1220.     var i32x iAngle;
  1221.     var f32x fAngle;
  1222.     var szx szAngleText;
  1223.  
  1224.     fAngle = GetActiveCyclistSplineAngle()*100.0;
  1225.  
  1226.     if(fAngle>3)
  1227.     {
  1228.         // Cote
  1229.         SetContainerSprite(oRace.iAngleIconID,0,0);
  1230.     }
  1231.     else if(fAngle<-3)
  1232.     {
  1233.         // pente
  1234.         SetContainerSprite(oRace.iAngleIconID,2,0);
  1235.     }
  1236.     else
  1237.     {
  1238.         // plat
  1239.         SetContainerSprite(oRace.iAngleIconID,1,0);
  1240.     }
  1241.     iAngle = fAngle;
  1242.     fAngle = fAngle - iAngle;
  1243.     fAngle = fAngle * 10.0;
  1244.     szAngleText = itoa(iAngle);
  1245.     if(fAngle<0)
  1246.         fAngle=-fAngle;
  1247.  
  1248.     iAngle = fAngle;
  1249.     szAngleText = strcat(szAngleText,".");
  1250.     szAngleText = strcat(szAngleText,itoa(iAngle));
  1251.     SetContainerText(oRace.iAngleTextID,strcat(szAngleText,"%"));
  1252. }
  1253.  
  1254. func void vUpdate_TissotWatch()
  1255. {
  1256.     var i32x iDelta;
  1257.     var i32x iDay,iHour,iMin,iSec,ok;
  1258.     var szx szDelta;
  1259.     
  1260.     // Update phase duration
  1261.     iDelta = (GetInRaceTime()*10.0);
  1262.     
  1263.     iHour = iDelta/3600;
  1264.     iDelta = iDelta % 3600;
  1265.     
  1266.     iMin = iDelta/60;
  1267.     iDelta = iDelta % 60;
  1268.     
  1269.     iSec = iDelta;
  1270.     ok = 0;
  1271.     
  1272.     szDelta = "";
  1273.     
  1274.     // Hour
  1275.     if(iHour>=10)
  1276.     {
  1277.         szDelta = itoa(iHour);
  1278.     }
  1279.     else if(iHour>0)
  1280.     {
  1281.         szDelta = strcat("0",itoa(iHour));
  1282.     }
  1283.     else
  1284.     {
  1285.         szDelta = "00";
  1286.     }
  1287.     szDelta = strcat(szDelta,":");
  1288.     
  1289.     
  1290.     // Minute
  1291.     if(iMin>=10)
  1292.     {
  1293.         szDelta = strcat(szDelta,itoa(iMin));
  1294.     }
  1295.     else if(iMin>0)
  1296.     {
  1297.         szDelta = strcat(szDelta,"0");
  1298.         szDelta = strcat(szDelta,itoa(iMin));
  1299.     }
  1300.     else
  1301.     {
  1302.         szDelta = strcat(szDelta,"00");
  1303.     }
  1304.     szDelta = strcat(szDelta,":");
  1305.     
  1306.     // Seconde
  1307.     if(iSec>=10)
  1308.     {
  1309.         szDelta = strcat(szDelta,itoa(iSec));
  1310.     }
  1311.     else if(iSec>0)
  1312.     {
  1313.         szDelta = strcat(szDelta,"0");
  1314.         szDelta = strcat(szDelta,itoa(iSec));
  1315.     }
  1316.     else
  1317.     {
  1318.         szDelta = strcat(szDelta,"00");
  1319.     }
  1320.     
  1321.     SetContainerText(oRace.m_cLCD,szDelta);
  1322. }
  1323. // *************************************
  1324. // Team Time Trial structure initializer
  1325. // *************************************
  1326. func void vRaz_RaceTimeTrialResults()
  1327. {
  1328.     var i32x iNumSprint,iNbSprints,iNbCyclistsRecorded,boucle,i;
  1329.     // Raz sprint result array
  1330.     iNbSprints = 16;
  1331.     iNumSprint=0;
  1332.     while(iNumSprint<iNbSprints)
  1333.     {
  1334.         iNbCyclistsRecorded=20;
  1335.         boucle=0;
  1336.         while(boucle<iNbCyclistsRecorded)
  1337.         {
  1338.             i=0;
  1339.             while(i<20)
  1340.             {
  1341.                 oRace.Tab_Team_Sprints[iNumSprint].Tab[i].iNbCyclistsRecorded=0;
  1342.                 oRace.Tab_Team_Sprints[iNumSprint].Tab[i].fSprintTime=0.0;
  1343.                 oRace.Tab_Team_Sprints[iNumSprint].Tab[i].iCyclistID=0;
  1344.                 i=i+1;
  1345.             }
  1346.             oRace.TabSprintClassement[iNumSprint].TabSprintClassement[oRace.TabSprintClassement[iNumSprint].iNbTeamRecorded].iTeamID=0;
  1347.             oRace.TabSprintClassement[iNumSprint].iNbTeamRecorded=0;
  1348.             
  1349.             boucle=boucle+1;
  1350.         }
  1351.         iNumSprint=iNumSprint+1;
  1352.     }
  1353. }
  1354. func void vInit_RaceTimeTrialResults()
  1355. {
  1356.     var i32x iNumSprint,iNbSprints,iNbCyclistsRecorded,boucle,iTeamID,iCyclistID;
  1357.     var f32x fCyclistTime;
  1358.  
  1359.     iNbSprints=GetNbSprints();
  1360.     iNumSprint=0;
  1361.     while(iNumSprint<iNbSprints)
  1362.     {
  1363.         iNbCyclistsRecorded=GetSprintNumRecordedCyclists(iNumSprint);
  1364.         boucle=0;
  1365.         while(boucle<iNbCyclistsRecorded)
  1366.         {
  1367.             iCyclistID=GetSprintCyclistPreRaceIndex(iNumSprint,boucle);
  1368.             iTeamID=GetCyclistPreRaceTeamID(iCyclistID);
  1369.  
  1370.             fCyclistTime=GetSprintCyclistTime(iNumSprint,boucle);
  1371.  
  1372.     
  1373.             oRace.Tab_Team_Sprints[iNumSprint].Tab[iTeamID].iNbCyclistsRecorded=oRace.Tab_Team_Sprints[iNumSprint].Tab[iTeamID].iNbCyclistsRecorded+1;
  1374.             // si cinquieme cycliste, enregistrement du temps
  1375.             if (oRace.Tab_Team_Sprints[iNumSprint].Tab[iTeamID].iNbCyclistsRecorded==5)
  1376.             {
  1377.                 oRace.Tab_Team_Sprints[iNumSprint].Tab[iTeamID].fSprintTime=fCyclistTime;
  1378.                 oRace.Tab_Team_Sprints[iNumSprint].Tab[iTeamID].iCyclistID=iCyclistID;
  1379.                 /*print("cinquieme cycliste:");
  1380.                 print(Join_GetStringFromSortedIndex(g_stInraceJoins.m_iCyclist_LastName,iCyclistID));
  1381.                 print("\n");*/
  1382.  
  1383.                 //classement de l'equipe
  1384.                 oRace.TabSprintClassement[iNumSprint].TabSprintClassement[oRace.TabSprintClassement[iNumSprint].iNbTeamRecorded].iTeamID=iTeamID;
  1385.                 oRace.TabSprintClassement[iNumSprint].iNbTeamRecorded=oRace.TabSprintClassement[iNumSprint].iNbTeamRecorded+1;
  1386.  
  1387.             }
  1388.             
  1389.             boucle=boucle+1;
  1390.         }
  1391.         iNumSprint=iNumSprint+1;
  1392.     }
  1393. }
  1394.  
  1395.  
  1396. func void Race_Create ()
  1397. {
  1398.     var i32x i,iServerSpeed;
  1399.     oRace.iGroupsID=-1;
  1400.  
  1401.     oRacePodium.m_bPodiumSequenceLaunched = false;
  1402.     oRacePodium.m_bQueryAsked = false;
  1403.     
  1404.     //print("race mode:");
  1405.     //print(itoa(GetRaceMode()));
  1406.     //print("\n");
  1407.     //Save the mode for the race
  1408.     oRace.iInRaceMode=GetRaceMode();
  1409.  
  1410.     SetObjectSize(800, 600);
  1411.     SetComponentNumber(36);
  1412.     
  1413.     oRace.pRace=GetParserComponent();
  1414.     //print("SetUpdateGroupsFunc\n\n");
  1415.     //Set the function pointer that will be called by inrace
  1416.     SetUpdateGroupsFunc(UpdateGroups);
  1417.     CameraDrawTarget(0);
  1418.     //Camera management
  1419.     CreateInRaceCameras(oRace.iNbCameras);
  1420.     CreatePodiumInRaceCameras(oRace.iPodiumNbCameras);
  1421.  
  1422.     UpdateInRaceCameraPositions();
  1423.     SetActiveCamera(0);
  1424.     SelectInRaceCamera(oRace.iCurrentCamera);
  1425.     
  1426.     // Left Border (camera settings...)
  1427.     i= InitContainer(t_panel_bordertopleft);
  1428.     SetContainerSprite(i,1,0);
  1429.     SetComponentPositionY(i,3);
  1430.     SetContainerScaleY(i,489.0/125.0);
  1431.     
  1432.     i= InitContainer(t_panel_borderbottomleft);
  1433.     SetComponentPosition(i,0,492);
  1434.  
  1435.     // Blue button
  1436.     i = InitContainer(tWatchTissot);
  1437.     SetEvents(i,GUI_NoEvent);
  1438.     SetContainerSize(i,74,74);
  1439.     SetComponentPosition(i,6,495);
  1440.     SetContainerSprite(i,1,0);
  1441.  
  1442.     oRace.m_cLCD = InitContainer(tFntLcd);
  1443.     SetEvents(oRace.m_cLCD ,GUI_NoEvent);
  1444.     SetContainerScale(oRace.m_cLCD,0.25,0.28);
  1445.     SetComponentPosition(oRace.m_cLCD ,20,526);
  1446.     SetContainerText(oRace.m_cLCD,"0");
  1447.     
  1448.     Panel_Team_Tactic_Profil_InitMembers(g_oGameConfig.m_iCurrentStageID,0,1,624,75,42,6);
  1449.     oRace.iProfileMeshID = InitObject(oPanel_Team_Tactic_Profil.szName, oPanel_Team_Tactic_Profil.oFunc.pcreate, oPanel_Team_Tactic_Profil.oFunc.pevent);
  1450.     SetStackEvents(oRace.iProfileMeshID,GUI_Destroy | GUI_Char|GUI_KeyDown);
  1451.  
  1452.     //Call the function to groups in interface
  1453.     Groups_Init(GetInRaceMode());
  1454.     oRace.iGroupsID = InitObject("Groups", oGroups.oFunc.pcreate, oGroups.oFunc.pevent);
  1455.     //SetStackEvents(oRace.iGroupsID, GUI_Mouse|GUI_Key);
  1456.     SetComponentPosition(oRace.iGroupsID,oProfileCamera.m_iWindowPosX,oProfileCamera.m_iWindowPosY);
  1457.     SetComponentWidth(oRace.iGroupsID,oProfileCamera.m_iWindowWidth);
  1458.     SetComponentHeight(oRace.iGroupsID,oProfileCamera.m_iWindowHeight);
  1459.     SetComponentClipper(oRace.iGroupsID,0,0,oProfileCamera.m_iWindowWidth,oProfileCamera.m_iWindowHeight);
  1460.     
  1461.     // Profil cadre
  1462.     i=InitContainer(tCommonTableBorder);
  1463.     SetContainerSize(i,17,85);
  1464.     SetContainerColor(i,c_VLightGray);
  1465.     SetEvents(i,GUI_NoEvent);
  1466.  
  1467.     i=InitContainer(tCommonTableBorder);
  1468.     SetComponentPositionX(i,679);
  1469.     SetContainerSize(i,16,85);
  1470.     SetContainerColor(i,c_VLightGray);
  1471.     SetEvents(i,GUI_NoEvent);
  1472.  
  1473.     i=Init_LibObject_Cadre(t_panel_profil,663,85);
  1474.     SetComponentPositionX(i,16);
  1475.     SetEvents(i,GUI_NoEvent);
  1476.  
  1477.     // Picking window
  1478.     PickingWindow_Init();
  1479.     oRace.iPickingWindowID = InitObject("PickingWindow", oPickingWindow.oFunc.pcreate, oPickingWindow.oFunc.pevent);
  1480.     SetComponentPosition(oRace.iPickingWindowID,oRace.o3DViewport.iX,oRace.o3DViewport.iY);
  1481.     SetStackEvents(oRace.iPickingWindowID,GUI_MouseDown|GUI_MouseRoll);
  1482.  
  1483.  
  1484.     //initialisation du tableau de sprints par equipe si TTT
  1485.     vRaz_RaceTimeTrialResults();
  1486.     if (GetInRaceMode()==G_iRaceModeTeamTimeTrial)
  1487.     {
  1488.         vInit_RaceTimeTrialResults();
  1489.     }
  1490.     
  1491.     
  1492.     // Panel inrace tab
  1493.     Panel_Inrace_Tab_InitMembers();
  1494.     oRace.iPanelTabID=InitObject(oPanel_Inrace_Tab.szName,oPanel_Inrace_Tab.oFunc.pcreate,oPanel_Inrace_Tab.oFunc.pevent);
  1495.     SetComponentPosition(oRace.iPanelTabID,0,85);
  1496.     
  1497.     // **************
  1498.     // Profil button
  1499.     // **************
  1500.     // Plus button zoom +
  1501.     i=InitButton(tBtnZoomPlus);
  1502.     SetComponentPosition(i,15,4);
  1503.     SetContainerStateFunc(i,ButtonState);
  1504.     SetContainerHelpIndex(i,1486);
  1505.     oRace.iButtonZoomPlusID=i;
  1506.  
  1507.     // Minus button zoom -
  1508.     i=InitButton(tBtnZoomMinus);
  1509.     SetComponentPosition(i,12,31);
  1510.     SetContainerHelpIndex(i,1487);
  1511.     SetContainerStateFunc(i,ButtonState);
  1512.     oRace.iButtonZoomMoinsID=i;
  1513.     
  1514.  
  1515.     // Normal zoom
  1516.     i=InitButton(tBtnZoomDef);
  1517.     SetComponentPosition(i,9,58);
  1518.     SetContainerStateFunc(i,ButtonState);
  1519.     SetContainerHelpIndex(i,1488);
  1520.     oRace.iButtonZoomDefID=i;
  1521.     
  1522.     
  1523.     // Strafe left
  1524.     i=InitButton(t_leftarrow);
  1525.     SetComponentRepeatState(i,5);
  1526.     SetContainerStateFunc(i,StrafeProfil_ButtonState);
  1527.     SetContainerHelpIndex(i,1489);
  1528.     SetComponentPosition(i,10,91);
  1529.     oRace.iStrafeLeft=i;
  1530.     
  1531.     // Strafe right
  1532.     i=InitButton(t_rightarrow);
  1533.     SetComponentRepeatState(i,5);
  1534.     SetContainerHelpIndex(i,1490);
  1535.     SetContainerStateFunc(i,StrafeProfil_ButtonState);
  1536.     SetComponentPosition(i,30,91);
  1537.     oRace.iStrafeRight=i;
  1538.     
  1539.     // Speed X1
  1540.     i=InitRadioButton(t_changespeed);
  1541.     SetContainerStateFunc(i,ButtonSpeedState_1);
  1542.     SetContainerHelpIndex(i,1528);
  1543.     SetComponentPosition(i,574,82);
  1544.     SetComponentSize(i,20,15);
  1545.     oRace.iSpeedX1=i;
  1546.  
  1547.     // Speed X2
  1548.     i=InitRadioButton(t_changespeed);
  1549.     SetContainerStateFunc(i,ButtonSpeedState_2);
  1550.     SetContainerHelpIndex(i,1528);
  1551.     SetComponentPosition(i,598,82);
  1552.     SetComponentSize(i,20,15);
  1553.     oRace.iSpeedX2=i;
  1554.     
  1555.     // Speed X4
  1556.     i=InitRadioButton(t_changespeed);
  1557.     SetContainerStateFunc(i,ButtonSpeedState_3);
  1558.     SetContainerHelpIndex(i,1528);
  1559.     SetComponentPosition(i,622,82);
  1560.     SetComponentSize(i,20,15);
  1561.     oRace.iSpeedX4=i;
  1562.  
  1563.     // Speed X8
  1564.     i=InitRadioButton(t_changespeed);
  1565.     SetContainerStateFunc(i,ButtonSpeedState_4);
  1566.     SetContainerHelpIndex(i,1528);
  1567.     SetComponentPosition(i,646,82);
  1568.     SetComponentSize(i,20,15);
  1569.     oRace.iSpeedX8=i;
  1570.  
  1571.     iServerSpeed = GetMSSpeed();
  1572.  
  1573.     if(iServerSpeed == 1)
  1574.     {
  1575.         SetCheckboxState(oRace.iSpeedX1,1);
  1576.         SetCheckboxState(oRace.iSpeedX2,0);
  1577.         SetCheckboxState(oRace.iSpeedX4,0);
  1578.         SetCheckboxState(oRace.iSpeedX8,0);
  1579.     }
  1580.     if(iServerSpeed == 2)
  1581.     {
  1582.         SetCheckboxState(oRace.iSpeedX1,0);
  1583.         SetCheckboxState(oRace.iSpeedX2,1);
  1584.         SetCheckboxState(oRace.iSpeedX4,0);
  1585.         SetCheckboxState(oRace.iSpeedX8,0);
  1586.     }
  1587.     if(iServerSpeed == 4)
  1588.     {
  1589.         SetCheckboxState(oRace.iSpeedX1,0);
  1590.         SetCheckboxState(oRace.iSpeedX2,0);
  1591.         SetCheckboxState(oRace.iSpeedX4,1);
  1592.         SetCheckboxState(oRace.iSpeedX8,0);
  1593.     }
  1594.     if(iServerSpeed == 8)
  1595.     {
  1596.         SetCheckboxState(oRace.iSpeedX1,0);
  1597.         SetCheckboxState(oRace.iSpeedX2,0);
  1598.         SetCheckboxState(oRace.iSpeedX4,0);
  1599.         SetCheckboxState(oRace.iSpeedX8,1);
  1600.     }
  1601.  
  1602.     if(IsAdmin() == 0)
  1603.     {
  1604.         SetComponentEnableStatus(oRace.iSpeedX1, 0);
  1605.         SetComponentEnableStatus(oRace.iSpeedX2, 0);
  1606.         SetComponentEnableStatus(oRace.iSpeedX4, 0);
  1607.         SetComponentEnableStatus(oRace.iSpeedX8, 0);
  1608.     }
  1609.  
  1610.     
  1611.     // **************
  1612.     // Race Events
  1613.     // **************
  1614.     //init event log
  1615.     Panel_Inrace_EventLog_InitMembers();
  1616.     oRace.iLogWindow = ID_NOT_CREATED;
  1617.  
  1618.     //init the chat window
  1619.     Panel_Inrace_Chat_InitMembers();
  1620.     oRace.iChatWindow = ID_NOT_CREATED;
  1621.  
  1622.     // Init Event display
  1623.     RaceEvent_Init();
  1624.     oRace.iEventID = InitObject("RaceEvent", oRaceEvent.oFunc.pcreate, oRaceEvent.oFunc.pevent);
  1625.     SetComponentPosition(oRace.iEventID, 32, 200);
  1626.  
  1627.     // Init Chat display
  1628.     RaceChat_Init();
  1629.     oRace.iChatID = InitObject("RaceChat", oRaceChat.oFunc.pcreate, oRaceChat.oFunc.pevent);
  1630.     SetComponentPosition(oRace.iChatID, 100, 480);
  1631.  
  1632.     // Team panel
  1633.     InitTeamPanel();
  1634.     oRace.iPanelID = InitObject(oTeamPanel.szName, oTeamPanel.oFunc.pcreate, oTeamPanel.oFunc.pevent);
  1635.     SetComponentPosition(oRace.iPanelID, 672, 0);
  1636.  
  1637.     // Init Active cyclist
  1638.     InitActiveCyclist();
  1639.     
  1640.     oRace.iInfoIAID=InitContainer(tFontArial);
  1641.     SetComponentPosition(oRace.iInfoIAID,0,180);
  1642.     SetEvents(oRace.iInfoIAID,GUI_NoEvent);
  1643.     
  1644.     // Tool bar
  1645.     ToolBar_init_members();
  1646.     oRace.m_cToolBar = InitObject("Tool Bar",oToolBar.ofunc.pcreate,oToolBar.ofunc.pevent);
  1647.     SetComponentPosition(oRace.m_cToolBar,0,574);
  1648.     Set_Config_Button_VisibleStatus(false);
  1649.  
  1650.     // Chat command
  1651.     if (g_oGameConfig.m_iSinglePlayer==0)
  1652.     {
  1653.         oRace.m_cChatButton = InitButton(tBtnChat);
  1654.         SetContainerStateFunc(oRace.m_cChatButton,ButtonState);
  1655.         SetContainerHelpIndex(oRace.m_cChatButton,1552);
  1656.         SetComponentPosition(oRace.m_cChatButton,720,578);
  1657.         SetContainerScale(oRace.m_cChatButton,0.65,0.65);
  1658.     }
  1659.  
  1660.     // Lag indicator
  1661.     oRace.m_cLagIndicator = InitContainer(tBtnLag);
  1662.     SetComponentPosition(oRace.m_cLagIndicator,33,545);
  1663.     SetContainerSize(oRace.m_cLagIndicator,20,20);
  1664.     SetComponentVisibleStatus(oRace.m_cLagIndicator,0);
  1665.     SetEvents(oRace.m_cLagIndicator,GUI_NoEvent);
  1666.  
  1667.     // Create angle info container
  1668.     oRace.iAngleIconID = InitContainer(tPictoAngle);
  1669.     SetComponentPosition(oRace.iAngleIconID,536,500);
  1670.     SetEvents(oRace.iAngleIconID,GUI_NoEvent);
  1671.  
  1672.     oRace.iAngleTextID = InitContainer(tFontArial);
  1673.     SetComponentPosition(oRace.iAngleTextID,538,502);
  1674.     SetContainerColor(oRace.iAngleTextID, c_Black); //black
  1675.     SetEvents(oRace.iAngleTextID,GUI_NoEvent);
  1676.  
  1677.     RefreshPictoAngle();
  1678.         //create the wind info container
  1679.     //tPictoVent
  1680.     oRace.iWindIconID = InitContainer(tPictoVent);
  1681.     SetComponentPosition(oRace.iWindIconID,600,500);
  1682.     SetEvents(oRace.iWindIconID,GUI_NoEvent);
  1683.  
  1684.     oRace.iWindTextID = InitContainer(tFontArial);
  1685.     SetComponentPosition(oRace.iWindTextID,602,502);
  1686.     SetContainerColor(oRace.iWindTextID, c_Black); //black
  1687.     SetEvents(oRace.iWindTextID,GUI_NoEvent);
  1688.  
  1689.     RefreshPictoVent();
  1690.     
  1691.     // Select first component
  1692.     SetSelectedComponent(0);
  1693.  
  1694.     // No pause dialog
  1695.     oRace.m_cPause = ID_NOT_CREATED;
  1696.  
  1697.     oRace.iCompteurFPS = 0;
  1698.     oRace.iCompteurLag = 0;
  1699.     
  1700.     RefreshInfos();
  1701.     
  1702.     oRace.ploop = FollowCyclistCamera;
  1703.     SetLoopFunc(oRace.ploop);
  1704.     
  1705.     print("debug : race created...\n");
  1706.     
  1707. }
  1708. func void vInRace_ManageShortcut(i32x _iKey)
  1709. {
  1710.     var i32x i;
  1711.     if (_iKey == VK_F2)
  1712.     {
  1713.         SaveInRaceCameraPositions();
  1714.     }
  1715.     else if(_iKey==VK_Pause)
  1716.     {
  1717.         if(IsAdmin())
  1718.         {
  1719.             if(oRace.iCurrentSpeed != 0)
  1720.             {
  1721.                 // Ask pause
  1722.                 g_oMenuServer.m_oServer<<speed(0);
  1723.                 //print("PauseAsked\n");
  1724.             }
  1725.             else
  1726.             {
  1727.                 // Remove pause
  1728.                 g_oMenuServer.m_oServer<<speed(1);
  1729.                 //print("PauseRemoved\n");
  1730.             }
  1731.         }
  1732.     }
  1733.     else if(_iKey==VK_Right)
  1734.     {
  1735.         if(GetActiveCamera()==0)
  1736.             if (!GetKeyState(DIK_RCONTROL))
  1737.                 if (!GetKeyState(DIK_RSHIFT))
  1738.                 {
  1739.                     //print("*** KEY_RIGHT : NextActiveCyclist \n");
  1740.                     
  1741.                     // next active cyclist
  1742.                     oPanelRank.m_bSeeClass=true;
  1743.                     SetNextActiveCyclist();
  1744.                     vSetProfileCameraMode(0);
  1745.                     RefreshInfos();
  1746.                 }
  1747.     }
  1748.     else if(_iKey==VK_Left)
  1749.     {
  1750.         if(GetActiveCamera()==0)
  1751.             if (!GetKeyState(DIK_RCONTROL))
  1752.                 if (!GetKeyState(DIK_RSHIFT))
  1753.                 {
  1754.                     //print("*** KEY_LEFT : PreviousActiveCyclist \n");
  1755.                     
  1756.                     // next active cyclist
  1757.                     oPanelRank.m_bSeeClass=true;
  1758.                     SetPreviousActiveCyclist();
  1759.                     vSetProfileCameraMode(0);
  1760.                     RefreshInfos();
  1761.                 }
  1762.     }
  1763.     else if(_iKey==VK_Up)
  1764.     {
  1765.         if(GetActiveCamera()==0)
  1766.             if (!GetKeyState(DIK_RCONTROL))
  1767.                 if (!GetKeyState(DIK_RSHIFT))
  1768.                 {
  1769.                     //print("*** KEY_RIGHT : NextActiveCyclistInTeam \n");
  1770.                     
  1771.                     // next active cyclist
  1772.                     oPanelRank.m_bSeeClass=true;
  1773.                     SetPreviousActiveCyclistInTeam(g_oUser.m_iMyInRaceTeamID);
  1774.                     vSetProfileCameraMode(0);
  1775.                     RefreshInfos();
  1776.                 }
  1777.     }
  1778.     else if(_iKey==VK_Down)
  1779.     {
  1780.         if(GetActiveCamera()==0)
  1781.             if (!GetKeyState(DIK_RCONTROL))
  1782.                 if (!GetKeyState(DIK_RSHIFT))
  1783.                 {
  1784.                     //print("*** KEY_LEFT : PreviousActiveCyclist \n");
  1785.                     
  1786.                     // next active cyclist
  1787.                     oPanelRank.m_bSeeClass=true;
  1788.                     SetNextActiveCyclistInTeam(g_oUser.m_iMyInRaceTeamID);
  1789.                     vSetProfileCameraMode(0);
  1790.                     RefreshInfos();
  1791.                 }
  1792.     }
  1793.     else if (_iKey == VK_A)
  1794.     {
  1795.         //print("*** Calling vSetProfileCameraMode(1) and move camera left \n");
  1796.         vMoveProfileCamera(-2.0,1);
  1797.     }
  1798.     else if(_iKey == VK_Z)
  1799.     {
  1800.         //print("*** Calling vSetProfileCameraMode(1) and move camera right \n");
  1801.         vMoveProfileCamera(2.0,1);
  1802.     }
  1803.     
  1804.     else if (_iKey == VK_Add)
  1805.     {
  1806.         //if (GetKeyState(DIK_RCONTROL))
  1807.         {
  1808.             //print("*** Calling vRaceSetProfileZoom ++ \n");
  1809.             vRaceSetProfileZoom((oProfileCamera.m_iZoomIndex+1));
  1810.         }
  1811.     }
  1812.     
  1813.     else if (_iKey == VK_Subtract)
  1814.     {
  1815.         //if (GetKeyState(DIK_RCONTROL))
  1816.         {
  1817.             //print("*** Calling vRaceSetProfileZoom -- \n");
  1818.             vRaceSetProfileZoom((oProfileCamera.m_iZoomIndex-1));
  1819.         }
  1820.     }
  1821.     else if (_iKey == VK_Space)
  1822.     {
  1823.         vSetProfileCameraMode(0);
  1824.     }
  1825.     else if (_iKey == VK_F8)
  1826.     {
  1827.         if(oRace.iLogWindow != ID_NOT_CREATED)
  1828.         {
  1829.             // Delete Chat Window
  1830.             DeleteComponent(oRace.iLogWindow);
  1831.             oRace.iLogWindow = ID_NOT_CREATED;
  1832.         }
  1833.         else
  1834.         {
  1835.             if(!oRacePodium.m_bPodiumSequenceLaunched)
  1836.             {
  1837.                 // Create chat window
  1838.                 oRace.iLogWindow=InitObject("log",oPanelInraceEventLog.oFunc.pcreate,oPanelInraceEventLog.oFunc.pevent);
  1839.                 SetComponentPosition(oRace.iLogWindow,75,225);
  1840.             }
  1841.         }
  1842.     }
  1843.     else if (_iKey == VK_F3)
  1844.     {
  1845.         if(oRace.iChatWindow != ID_NOT_CREATED)
  1846.         {
  1847.             // Delete Chat Window
  1848.             DeleteComponent(oRace.iChatWindow);
  1849.             oRace.iChatWindow = ID_NOT_CREATED;
  1850.         }
  1851.         else
  1852.         {
  1853.             if(!oRacePodium.m_bPodiumSequenceLaunched)
  1854.             {
  1855.                 // Create chat window
  1856.                 oRace.iChatWindow=InitObject("chat",oPanelInraceChat.oFunc.pcreate,oPanelInraceChat.oFunc.pevent);
  1857.                 SetComponentPosition(oRace.iChatWindow,50,200);
  1858.             }
  1859.         }
  1860.     }
  1861.     // debug : special demo
  1862.     else if ((_iKey == VK_F4)&&(G_iDebugVersion))
  1863.     {
  1864.         //Change fog
  1865.         oRace.iCurrentFog=oRace.iCurrentFog+1;
  1866.         if (oRace.iCurrentFog>=oRace.iNbFogs)
  1867.             oRace.iCurrentFog=0;
  1868.         SelectFog(oRace.iCurrentFog);
  1869.     }
  1870.     
  1871.     else if ((_iKey == VK_F5)&&(G_iDebugVersion)&&(GetActiveCamera()!=4))
  1872.     {
  1873.         if (GetActiveCamera()!=2)
  1874.         {
  1875.             oRace.bDrawCameraTarget=0;
  1876.             CameraDrawTarget(0);
  1877.             SetActiveCamera(2);
  1878.             oRace.ploop = ManPathCamera;
  1879.             SetLoopFunc(oRace.ploop);
  1880.             ShowMouse();
  1881.         }
  1882.         else
  1883.         {
  1884.             //Change camera path
  1885.             oRace.iCurrentCamera=oRace.iCurrentCamera+1;
  1886.             if (oRace.iCurrentCamera>=oRace.iNbCameras)
  1887.                 oRace.iCurrentCamera=0;
  1888.             SelectInRaceCamera(oRace.iCurrentCamera);
  1889.         }
  1890.     }
  1891.     // debug : special demo
  1892.     else if ((_iKey == VK_F7)&&(GetActiveCamera()!=4))
  1893.     {
  1894.         if (GetActiveCamera()!=0)
  1895.         {
  1896.             SetActiveCamera(0);
  1897.             oRace.ploop = FollowCyclistCamera;
  1898.             SetLoopFunc(oRace.ploop);
  1899.         }
  1900.         else
  1901.         {
  1902.             //Change camera path
  1903.             oRace.iCurrentCamera=oRace.iCurrentCamera+1;
  1904.             PlaySound(0,sbClickSound[5]);
  1905.             
  1906.             if (oRace.iCurrentCamera>=oRace.iNbCameras)
  1907.                 oRace.iCurrentCamera=0;
  1908.             SelectInRaceCamera(oRace.iCurrentCamera);
  1909.         }
  1910.     }
  1911.     else if (_iKey == VK_PageUp)
  1912.     {
  1913.         PushEventOnChild(oRace.iPanelID,GUI_PANEL_UP);
  1914.     }
  1915.     else if (_iKey == VK_PageDown)
  1916.     {
  1917.         PushEventOnChild(oRace.iPanelID,GUI_PANEL_DOWN);
  1918.     }
  1919.     else if ((_iKey>=VK_1) && (_iKey<=VK_9))
  1920.     {
  1921.         // Don't make camera change when chat is open
  1922.         if(oRace.iChatWindow == ID_NOT_CREATED)
  1923.         {
  1924.             // choose camera for cyclist or sprint
  1925.             i = _iKey - VK_1;
  1926.             if ((GetActiveCamera()==0) || (GetActiveCamera()==3))
  1927.             {
  1928.                 if (i<oRace.iNbCameras)
  1929.                 {
  1930.                     oRace.iCurrentCamera=i;
  1931.                     SelectInRaceCamera(i);
  1932.                 }
  1933.             }
  1934.         }
  1935.     }
  1936.     
  1937.     /* 
  1938.     else if (GetLastKey() == VK_F6)
  1939.     {
  1940.     oRace.bDrawCameraTarget=0;
  1941.     CameraDrawTarget(0);
  1942.     
  1943.       oRace.ploop = DoomCamera;
  1944.       SetActiveCamera(1);
  1945.       HideMouse();
  1946.       SetLoopFunc(oRace.ploop);
  1947.       }
  1948.     */
  1949. }
  1950. //----------------------------------------------------------------------------------------------------------------//
  1951. //----------------------------------------------------------------------------------------------------------------//
  1952. //Race Window Event func
  1953. //----------------------------------------------------------------------------------------------------------------//
  1954. //----------------------------------------------------------------------------------------------------------------//
  1955. func i32x Race (i32x _iComponentID,i32x _iEvent)
  1956. {
  1957.     var i32x i;
  1958.     var i32x iKey;
  1959.     if (_iComponentID == -1)
  1960.     {
  1961.         if(_iEvent == GUI_COMPONENT_KEYDOWN )
  1962.         {
  1963.             iKey = GetLastKey();
  1964.             vInRace_ManageShortcut(iKey);
  1965.         }
  1966.  
  1967.         if(_iEvent == GUI_COMPONENT_REFRESH )
  1968.         {
  1969.             var i32x iCyclist,iServerSpeed;
  1970.             var f32x fRacePerc;
  1971.  
  1972.  
  1973.             // Update Tissot watch
  1974.             vUpdate_TissotWatch();
  1975.  
  1976.             if(oRace.iCompteurLag == 6)
  1977.             {
  1978.                 oRace.iCompteurLag = 0;
  1979.                 if(GetNetLatency() > 8.0)    // If Net latency greater than 8.0 : warning
  1980.                 {
  1981.                     SetContainerSprite(oRace.m_cLagIndicator,0,0);
  1982.                     SetComponentVisibleStatus(oRace.m_cLagIndicator,1);
  1983.                 }
  1984.                 else if(GetNetLatency() >= 4.0)    // If 4.0 <= Net latency < 8.0 :  little warning
  1985.                 {
  1986.                     SetContainerSprite(oRace.m_cLagIndicator,1,0);
  1987.                     SetComponentVisibleStatus(oRace.m_cLagIndicator,1);
  1988.                 }
  1989.                 else    // If Net latency < 4.0 : No warning
  1990.                 {
  1991.                     SetComponentVisibleStatus(oRace.m_cLagIndicator,0);
  1992.                 }
  1993.             }
  1994.             else
  1995.                 oRace.iCompteurLag = oRace.iCompteurLag + 1;
  1996.             
  1997.  
  1998.             if(oRace.iCompteurFPS == 15)
  1999.             {
  2000.                 oRace.iCompteurFPS = 0;
  2001.                 if((oRace.iCurrentSpeed > 1) && IsAdmin())
  2002.                 {
  2003.                     if(GetFPS() < 3.0)
  2004.                     {
  2005.                         if(oRace.iCompteurRamageFPS < 5)
  2006.                             oRace.iCompteurRamageFPS = oRace.iCompteurRamageFPS + 1;
  2007.                         else
  2008.                         {
  2009.                             //special looprun
  2010.                             if(G_iLoopRunVersion==0)
  2011.                             {
  2012.                                 g_oMenuServer.m_oServer<<speed(oRace.iCurrentSpeed / 2);
  2013.                             }
  2014.                             oRace.iCompteurRamageFPS = 0;
  2015.                         }
  2016.                     }
  2017.                     else
  2018.                     {
  2019.                         oRace.iCompteurRamageFPS = 0;
  2020.                     }
  2021.                 }
  2022.             }
  2023.             else
  2024.                 oRace.iCompteurFPS = oRace.iCompteurFPS + 1;
  2025.             
  2026.             if(GetLineOnOff(Sound_eLine_Music))
  2027.             {
  2028.                 if(IsMp3Ended())
  2029.                 {
  2030.                     NextMp3();
  2031.                     SetMp3Volume(g_oUser.m_fMp3Volume);
  2032.                 }
  2033.             }
  2034.  
  2035.             iServerSpeed = GetMSSpeed();
  2036.  
  2037.             if(oRace.iCurrentSpeed != iServerSpeed)
  2038.             {
  2039.                 if(iServerSpeed == 0)
  2040.                 {
  2041.                     // Pause mode
  2042.                     SetCheckboxState(oRace.iSpeedX1,0);
  2043.                     SetCheckboxState(oRace.iSpeedX2,0);
  2044.                     SetCheckboxState(oRace.iSpeedX4,0);
  2045.                     SetCheckboxState(oRace.iSpeedX8,0);
  2046.                     // Create Pause dialog
  2047.                     if(oRace.m_cPause == ID_NOT_CREATED)
  2048.                     {
  2049.                         oRace.m_cPause = Dialog_Pause_Constructor();
  2050.                         SetComponentPosition(oRace.m_cPause,225,225);
  2051.                         SetEvents(oRace.iPanelID,GUI_NoEvent);
  2052.                     }
  2053.                 }
  2054.                 else
  2055.                 {
  2056.                     // Remove Pause dialog
  2057.                     if(oRace.m_cPause != ID_NOT_CREATED)
  2058.                     {
  2059.                         Dialog_Pause_Destructor();
  2060.                         oRace.m_cPause = ID_NOT_CREATED;
  2061.                         SetEvents(oRace.iPanelID,GUI_Destroy | GUI_MouseRoll | GUI_MouseMove | GUI_MouseUp | GUI_MouseDown | GUI_MouseEnter | GUI_MouseLeave | GUI_Key | GUI_Refresh | GUI_Enable | GUI_Disable);
  2062.                     }
  2063.  
  2064.                     if(iServerSpeed == 1)
  2065.                     {
  2066.                         SetCheckboxState(oRace.iSpeedX1,1);
  2067.                         SetCheckboxState(oRace.iSpeedX2,0);
  2068.                         SetCheckboxState(oRace.iSpeedX4,0);
  2069.                         SetCheckboxState(oRace.iSpeedX8,0);
  2070.                     }
  2071.                     else if(iServerSpeed == 2)
  2072.                     {
  2073.                         SetCheckboxState(oRace.iSpeedX1,0);
  2074.                         SetCheckboxState(oRace.iSpeedX2,1);
  2075.                         SetCheckboxState(oRace.iSpeedX4,0);
  2076.                         SetCheckboxState(oRace.iSpeedX8,0);
  2077.                     }
  2078.                     else if(iServerSpeed == 4)
  2079.                     {
  2080.                         SetCheckboxState(oRace.iSpeedX1,0);
  2081.                         SetCheckboxState(oRace.iSpeedX2,0);
  2082.                         SetCheckboxState(oRace.iSpeedX4,1);
  2083.                         SetCheckboxState(oRace.iSpeedX8,0);
  2084.                     }
  2085.                     else if(iServerSpeed == 8)
  2086.                     {
  2087.                         SetCheckboxState(oRace.iSpeedX1,0);
  2088.                         SetCheckboxState(oRace.iSpeedX2,0);
  2089.                         SetCheckboxState(oRace.iSpeedX4,0);
  2090.                         SetCheckboxState(oRace.iSpeedX8,1);
  2091.                     }
  2092.                 }
  2093.  
  2094.                 oRace.iCurrentSpeed = iServerSpeed;
  2095.             }
  2096.             if (g_oInRaceServer.m_iCanStartRace!=0)
  2097.             {
  2098.                 iCyclist = GetActiveCyclistPreRaceID();
  2099.                 fRacePerc = GetCyclistSplinePercentageDone(iCyclist);
  2100.  
  2101.                 
  2102.                 
  2103.                 var component pOld;
  2104.                 pOld = GetParserComponent();
  2105.                 SetParserComponent(GetObject(oRace.iProfileMeshID));
  2106.  
  2107.                 //ProfileCamera management
  2108.                 if (iGetProfileCameraMode()==0)
  2109.                 {
  2110.                     vSetProfileCameraPosition(fRacePerc);
  2111.                     vRefreshProfilePosition();
  2112.                 }
  2113.                 else if (oRace.bNeedRefreshProfilePosition)
  2114.                 {
  2115.                     vRefreshProfilePosition();
  2116.                     oRace.bNeedRefreshProfilePosition=0;
  2117.                 }
  2118.                 
  2119.                 if (oRace.bNeedRefreshProfileZoom)
  2120.                 {
  2121.                     vRefreshProfileZoom();
  2122.                     oRace.bNeedRefreshProfileZoom=0;
  2123.                 }
  2124.                 
  2125.                 SetParserComponent(pOld);
  2126.  
  2127.                 RefreshAIDrawInfos();
  2128.  
  2129.                 // Update event
  2130.                 InRaceEvents_UpdateListDisplay();
  2131.  
  2132.                 // Update chat
  2133.                 InRaceChat_UpdateDisplay();
  2134.  
  2135.                 //Groups position update
  2136.                 UpdateGroupsPositions();
  2137.                 UpdateSprintsPositions();
  2138.  
  2139.                 // Angle update
  2140.                 RefreshPictoAngle();
  2141.                 
  2142.                 //wind update
  2143.                 RefreshPictoVent();
  2144.                 
  2145.                 if(GetInRaceMode() != G_iRaceModeNormal)
  2146.                 {
  2147.                     // We're in time trial mode (team or individual)
  2148.                     // so update arrival time
  2149.                     Update_Sprint_List();
  2150.                 }
  2151.             }
  2152.             else
  2153.             {
  2154.                 // stop race
  2155.                 // debug : special demo
  2156.                 if((oRacePodium.m_bQueryAsked == false)&&(oRacePodium.m_bPodiumSequenceLaunched == false))
  2157.                 {
  2158.                     // 16:9 displays
  2159.                     SetRaceViewport(0, 75, 800, 450);
  2160.  
  2161.                     // Hide all component
  2162.                     oRace.bDrawCameraTarget=0;
  2163.                     CameraDrawTarget(0);
  2164.                     SelectInRaceCamera(1);
  2165.                     SetActiveCamera(2);
  2166.                     oRace.ploop = VoidCamera;
  2167.                     SetLoopFunc(oRace.ploop);
  2168.  
  2169.                     //Explore all the components and test if they still exist
  2170.                     i = 0;
  2171.                     while(i<34)
  2172.                     {
  2173.                         if(IsComponentValid(i))
  2174.                             //If the component still exists, hide it
  2175.                             SetComponentVisibleStatus(i,0);
  2176.                         i = i + 1;
  2177.                     }
  2178.  
  2179.                     // Play podium sound and stop music
  2180.                     PlaySoundLoop(1,sbCyclistsSound[2]);
  2181.                     if(GetLineOnOff(Sound_eLine_Music))
  2182.                     {
  2183.                         SetLineOnOff(Sound_eLine_Music,false);
  2184.                         StopMp3();
  2185.                         oRace.bMusicWasOnOff = true;
  2186.                     }
  2187.                     else
  2188.                         oRace.bMusicWasOnOff = false;
  2189.  
  2190.                     // Hide lag indicator
  2191.                     SetComponentVisibleStatus(oRace.m_cLagIndicator,0);
  2192.  
  2193.                     SetPodiumInRaceMode();
  2194.                     SetActiveCamera(4);
  2195.  
  2196.                     // Init podium object
  2197.                     oRace.m_cPodium = InitObject(
  2198.                         "Podium",
  2199.                         Object_Podium_Create,
  2200.                         Object_Podium_Event
  2201.                     );
  2202.  
  2203.                     SetStackEvents(oRace.m_cPodium,GUI_Destroy | GUI_Refresh);
  2204.                     SetRefreshState(oRace.m_cPodium,6,0);
  2205.                     
  2206.                     ResetQuery(QUERY_RACE_PODIUM);
  2207.                     GetQuery(g_oMenuServer.m_oServer,QUERY_RACE_PODIUM,"PodiumResult",CreatePodiumJoins, 0);
  2208.                     oRacePodium.m_bQueryAsked = true;
  2209.                 }
  2210.  
  2211.                 return 1;
  2212.             }
  2213.         }
  2214.     }
  2215.     else if(_iComponentID == oRace.iGroupsID)
  2216.     {
  2217.         if(_iEvent == GUI_RESET_SPRINTS )
  2218.         {
  2219.             PushEventOnChild(oRace.iProfileMeshID,GUI_RESET_SPRINTS);
  2220.         }
  2221.     }
  2222.     else if(_iComponentID == oRace.iPanelTabID)
  2223.     {
  2224.         if((_iEvent >= GUI_SPRINT_EVENT_MIN )&&(_iEvent<=GUI_SPRINT_EVENT_MAX))
  2225.         {
  2226.             PushEventOnChild(oRace.iGroupsID,GUI_RESET_GROUPS);
  2227.             PushEventOnChild(oRace.iProfileMeshID,_iEvent);
  2228.         }
  2229.     }
  2230.     else if(_iComponentID == oRace.iPanelID)
  2231.     {
  2232.         if(_iEvent == GUI_RESET_SPRINTS )
  2233.         {
  2234.             oGroups.m_iActive = 1;
  2235.             PushEventOnChild(oRace.iProfileMeshID,GUI_RESET_SPRINTS);
  2236.         }
  2237.     }
  2238.     else if(_iComponentID == oRace.iPickingWindowID)
  2239.     {
  2240.         if(_iEvent == GUI_RESET_SPRINTS )
  2241.         {
  2242.             oGroups.m_iActive = 1;
  2243.             PushEventOnChild(oRace.iProfileMeshID,GUI_RESET_SPRINTS);
  2244.         }
  2245.     }
  2246.     else if(_iComponentID == oRace.iSpeedX1)
  2247.     {
  2248.         if(_iEvent == GUI_RADIOBUTTON_CHANGED)
  2249.         {
  2250.         SetCheckboxState(oRace.iSpeedX2,0);
  2251.         SetCheckboxState(oRace.iSpeedX4,0);
  2252.         SetCheckboxState(oRace.iSpeedX8,0);
  2253.  
  2254.         g_oMenuServer.m_oServer<<speed(1);
  2255.         }
  2256.     }
  2257.     else if(_iComponentID == oRace.iSpeedX2)
  2258.     {
  2259.         if(_iEvent == GUI_RADIOBUTTON_CHANGED)
  2260.         {
  2261.         SetCheckboxState(oRace.iSpeedX1,0);
  2262.         SetCheckboxState(oRace.iSpeedX4,0);
  2263.         SetCheckboxState(oRace.iSpeedX8,0);
  2264.  
  2265.         g_oMenuServer.m_oServer<<speed(2);
  2266.         }
  2267.     }
  2268.     else if(_iComponentID == oRace.iSpeedX4)
  2269.     {
  2270.         if(_iEvent == GUI_RADIOBUTTON_CHANGED)
  2271.         {
  2272.         SetCheckboxState(oRace.iSpeedX1,0);
  2273.         SetCheckboxState(oRace.iSpeedX2,0);
  2274.         SetCheckboxState(oRace.iSpeedX8,0);
  2275.  
  2276.         g_oMenuServer.m_oServer<<speed(4);
  2277.         }
  2278.     }
  2279.     else if(_iComponentID == oRace.iSpeedX8)
  2280.     {
  2281.         if(_iEvent == GUI_RADIOBUTTON_CHANGED)
  2282.         {
  2283.         SetCheckboxState(oRace.iSpeedX1,0);
  2284.         SetCheckboxState(oRace.iSpeedX2,0);
  2285.         SetCheckboxState(oRace.iSpeedX4,0);
  2286.  
  2287.         g_oMenuServer.m_oServer<<speed(8);
  2288.         }
  2289.     }
  2290.     else if(_iComponentID == oRace.m_cPodium)
  2291.     {
  2292.         if(_iEvent == GUI_DESTROY_ME)
  2293.         {
  2294.             // load page news
  2295.             LoadPage(PAGE_ADMIN);
  2296.         }
  2297.     }
  2298.  
  2299.     // Roll on cyclist picking window
  2300.     else if (_iComponentID == oRace.iProfileMeshID)
  2301.     {
  2302.         if(_iEvent == GUI_COMPONENT_MOUSE_ROLL )
  2303.         {
  2304.             var i32x iMouseRoll;
  2305.             iMouseRoll=5*(GetMouseRoll()/240)+(GetMouseRoll()/120)%2;
  2306.             
  2307.             var i32x iStep;
  2308.             if (iMouseRoll>0)
  2309.             {
  2310.                 while(iMouseRoll>0)
  2311.                 {
  2312.                     vRaceSetProfileZoom((oProfileCamera.m_iZoomIndex+1));
  2313.                     iMouseRoll=iMouseRoll-1;
  2314.                 }
  2315.             }
  2316.             else
  2317.             {
  2318.                 while(iMouseRoll<0)
  2319.                 {
  2320.                     vRaceSetProfileZoom((oProfileCamera.m_iZoomIndex-1));
  2321.                     iMouseRoll=iMouseRoll+1;
  2322.                 }
  2323.             }
  2324.         }
  2325.         else if((_iEvent >= GUI_SPRINT_EVENT_MIN )&&(_iEvent<=GUI_SPRINT_EVENT_MAX))
  2326.         {
  2327.             SetActiveCamera(3);
  2328.             SetCameraSprint((_iEvent-GUI_SPRINT_EVENT_MIN));
  2329.             PushEventOnChild(oRace.iGroupsID,GUI_RESET_GROUPS);
  2330.         }
  2331.     }
  2332.     else if (_iComponentID == oRace.iButtonZoomMoinsID)
  2333.     {
  2334.         if(_iEvent == GUI_COMPONENT_MOUSE_LDOWN )
  2335.             PlaySound(0,sbClickSound[0]);
  2336.         if(_iEvent == GUI_BUTTON_PRESSED )
  2337.         {
  2338.             vRaceSetProfileZoom((oProfileCamera.m_iZoomIndex-1));
  2339.         }
  2340.     }
  2341.     else if (_iComponentID == oRace.iButtonZoomPlusID)
  2342.     {
  2343.         if(_iEvent == GUI_COMPONENT_MOUSE_LDOWN )
  2344.             PlaySound(0,sbClickSound[0]);
  2345.         if(_iEvent == GUI_BUTTON_PRESSED )
  2346.         {
  2347.             vRaceSetProfileZoom((oProfileCamera.m_iZoomIndex+1));
  2348.         }
  2349.     }
  2350.     else if(_iComponentID == oRace.iButtonZoomDefID)
  2351.     {
  2352.         if(_iEvent == GUI_COMPONENT_MOUSE_LDOWN )
  2353.             PlaySound(0,sbClickSound[0]);
  2354.         if(_iEvent == GUI_BUTTON_PRESSED )
  2355.         {
  2356.             vRaceSetProfileZoom(0);
  2357.         }
  2358.     }
  2359.     else if (_iComponentID == oRace.iStrafeRight)
  2360.     {
  2361.         if(_iEvent == GUI_COMPONENT_MOUSE_LDOWN )
  2362.             PlaySound(0,sbClickSound[0]);
  2363.         if(_iEvent == GUI_BUTTON_PRESSED )
  2364.         {
  2365.                 vMoveProfileCamera(2.0,1);
  2366.         }
  2367.     }
  2368.     else if (_iComponentID == oRace.iStrafeLeft)
  2369.     {
  2370.         if(_iEvent == GUI_COMPONENT_MOUSE_LDOWN )
  2371.             PlaySound(0,sbClickSound[0]);
  2372.         if(_iEvent == GUI_BUTTON_PRESSED )
  2373.         {
  2374.                 vMoveProfileCamera(-2.0,1);
  2375.         }
  2376.     }
  2377.     else if( _iComponentID == oRace.m_cChatButton)
  2378.     {
  2379.         if(_iEvent == GUI_BUTTON_PRESSED )
  2380.         {
  2381.             if(oRace.iChatWindow != ID_NOT_CREATED)
  2382.             {
  2383.                 // Delete Chat Window
  2384.                 DeleteComponent(oRace.iChatWindow);
  2385.                 oRace.iChatWindow = ID_NOT_CREATED;
  2386.             }
  2387.             else
  2388.             {
  2389.                 if(!oRacePodium.m_bPodiumSequenceLaunched)
  2390.                 {
  2391.                     // Create chat window
  2392.                     oRace.iChatWindow=InitObject("chat",oPanelInraceChat.oFunc.pcreate,oPanelInraceChat.oFunc.pevent);
  2393.                     SetComponentPosition(oRace.iChatWindow,50,200);
  2394.                 }
  2395.             }
  2396.         }
  2397.     }
  2398.     else if(_iEvent == GUI_QUIT_GAME)
  2399.         PushEvent(GUI_QUIT_GAME);
  2400.     
  2401.     return 1;
  2402. }
  2403.  
  2404.  
  2405.  
  2406.  
  2407. func void VoidCamera()
  2408. {
  2409.  
  2410. }
  2411.  
  2412.  
  2413. func void Page_Race_LoadData ()
  2414. {
  2415.     // create waiting dialog    
  2416.     CreateDialog(DIALOG_LOADING_DATA);
  2417.     
  2418.     // Get prerace data
  2419.     Dialog_Loading_Data_SetText(GetLocalizedFromGMKey(310));
  2420.  
  2421.     ResetQuery(QUERY_PRERACE_DATA);
  2422.     GetQuery(g_oMenuServer.m_oServer,QUERY_PRERACE_DATA,"PreRace",PreRaceDataOk, 1);
  2423. }
  2424.  
  2425. func void PreRaceDataOk()
  2426. {
  2427.     SetRaceViewport(oRace.o3DViewport.iX, oRace.o3DViewport.iY, oRace.o3DViewport.iW, oRace.o3DViewport.iH);
  2428.     NetClient_SetInterface(g_oMenuServer.m_oServer,iClientInRace);
  2429.     print("PreRace query received !\n");
  2430.     
  2431.     // init race client
  2432.     InitRaceClient();
  2433.  
  2434.     // this will start the udp handshake
  2435.     // when it is finished UDPHandshakeFinishedCB is called back
  2436.     Dialog_Loading_Data_SetText(GetLocalizedFromGMKey(311));
  2437.  
  2438.     // tutu debug : no udp authorization...
  2439.     //StartHandshake(g_oInRaceServer.m_szRServerIP,g_oInRaceServer.m_iRServerPort,g_oInRaceServer.m_szResolServerPass ,UDPHandshakeFinishedCB);
  2440.     if(g_oGameConfig.m_iSinglePlayer)
  2441.     {
  2442.         StartHandshake(g_oInRaceServer.m_szRServerIP,g_oInRaceServer.m_iRServerPort,"Cyanide",UDPHandshakeFinishedCB);
  2443.     }
  2444.     else
  2445.     {
  2446.         StartHandshake(g_oInRaceServer.m_szRServerIP,g_oInRaceServer.m_iRServerPort,g_oUser.m_szLogin ,UDPHandshakeFinishedCB);
  2447.     }
  2448. }
  2449.  
  2450.  
  2451. func void UDPHandshakeFinishedCB(i32x _iSuccess)
  2452. {
  2453. #checkpoint UDPHandshakeFinishedCB
  2454.     if (_iSuccess)
  2455.     {
  2456.         // ready to receive udp messages
  2457.         g_oMenuServer.m_oServer << mStartUDP();
  2458.         
  2459.         // Start wait for pos
  2460.         Dialog_Loading_Data_SetText(GetLocalizedFromGMKey(312));
  2461.         StartWaitForPos(WaitForPosFinishedCB);
  2462.     }
  2463.     else
  2464.     {
  2465.         // destroy waiting dialog
  2466.         DestroyDialog();
  2467.  
  2468.         // destroy race
  2469.         StopRace();
  2470.     }
  2471. }
  2472.  
  2473. func void WaitForPosFinishedCB(i32x _iSuccess)
  2474. {
  2475. #checkpoint WaitForPosFinishedCB
  2476.     if (_iSuccess)
  2477.     {
  2478.         //init control panels
  2479.         var i32x i;
  2480.         i=0;
  2481.         while(i<9)
  2482.         {
  2483.             oRace.a9_bControlPanelActivated[i]=0;
  2484.             i=i+1;
  2485.         }
  2486.  
  2487.         // create inrace joins
  2488.         CreateInraceJoins();
  2489.         
  2490.         // destroy waiting dialog
  2491.         DestroyDialog();
  2492. //        StopSound(1,sbMusicSound[0]);
  2493. //        StopSound(2,sbMusicSound[1]);
  2494.     
  2495.         // load inrace page (call Race_Constructor)
  2496.         InRace_LoadPage();
  2497.         
  2498.         // inform c++ to change loop
  2499.         StartRace();
  2500.  
  2501.         //Fog management
  2502.         CreateFogs(oRace.iNbFogs);
  2503.         UpdateFogsParameters();
  2504.         SelectFog(oRace.iCurrentFog);
  2505.  
  2506.         
  2507.         //send a message to the menuserver to say i am ready to receive interface,events,sprints
  2508.         g_oMenuServer.m_oServer<<mInRaceReady();
  2509.         
  2510.         //special looprun
  2511.         if(G_iLoopRunVersion)
  2512.         {
  2513.             g_oMenuServer.m_oServer<<speed(8);
  2514.             //g_oMenuServer.m_oServer<<delta(20);
  2515.         }
  2516.                 
  2517.     }
  2518.     else
  2519.     {
  2520.         // destroy waiting dialog
  2521.         DestroyDialog();
  2522.         
  2523.     }
  2524. }
  2525.  
  2526. //----------------------------------------------------------------------------------------------------------------//
  2527. //----------------------------------------------------------------------------------------------------------------//
  2528. //Constructor
  2529. //----------------------------------------------------------------------------------------------------------------//
  2530. //----------------------------------------------------------------------------------------------------------------//
  2531. func i32x Race_Constructor ()
  2532. {
  2533.     print("debug : race constructor...\n");
  2534.     
  2535.     oRace.iCurrentCamera=0;
  2536.     oRace.bDrawCameraTarget=0;
  2537.     
  2538.     oRace.bNeedRefreshProfileZoom=0;
  2539.     oRace.bNeedRefreshProfilePosition=0;
  2540.     oRace.iCurrentSpeed = 1;
  2541.         
  2542.     //PlaySoundLoop(2,sbMusicSound[1]);
  2543.     oRace.iWindowID = InitObject( oRace.szName, oRace.oFunc.pcreate,oRace.oFunc.pevent);
  2544.     
  2545.     SetStackEvents(oRace.iWindowID,GUI_Refresh|GUI_Char|GUI_KeyDown);    //416
  2546.     SetRefreshState(oRace.iWindowID,10,0);
  2547.     
  2548.     return oRace.iWindowID;
  2549. }
  2550.  
  2551. //----------------------------------------------------------------------------------------------------------------//
  2552. //----------------------------------------------------------------------------------------------------------------//
  2553. //Destructor
  2554. //----------------------------------------------------------------------------------------------------------------//
  2555. //----------------------------------------------------------------------------------------------------------------//
  2556. func void Race_Destructor ()
  2557. {
  2558. #checkpoint RACEDESTRUCTOR
  2559.     // inform menu server
  2560.     g_oMenuServer.m_oServer<<mStopUDP();
  2561.     
  2562.     // Destroy inrace joins
  2563.     DestroyInraceJoins();
  2564.  
  2565.     // tutu debug : end of race...
  2566.     NetClient_SetInterface(g_oMenuServer.m_oServer,iClientLogin);
  2567.     StopRace();
  2568.  
  2569.     ShowMouse();
  2570.     //DisplayToolsPanel();
  2571.     
  2572.     RazLoopFunc();
  2573.     
  2574.     //StopSound(2,sbMusicSound[1]);
  2575.     //PlaySoundLoop(2,sbMusicSound[1]);
  2576.     DeleteComponent(oRace.iWindowID);
  2577. }
  2578.  
  2579. //----------------------------------------------------------------------------------------------------------------//
  2580. //----------------------------------------------------------------------------------------------------------------//
  2581. //Race Window Init func
  2582. //----------------------------------------------------------------------------------------------------------------//
  2583. //----------------------------------------------------------------------------------------------------------------//
  2584. func void Race_InitMembers()
  2585. {
  2586.     oRace.szName = "Race";
  2587.     
  2588.     oRace.iNbCameras=9;
  2589.     oRace.iPodiumNbCameras=6;
  2590.  
  2591.     oRace.iNbFogs=4;
  2592.     
  2593.     oRace.o3DViewport.iX = 0;
  2594.     oRace.o3DViewport.iY = 98;
  2595.     oRace.o3DViewport.iW = 695;
  2596.     oRace.o3DViewport.iH = 502;
  2597.     
  2598.     oRace.oFunc.pcreate = Race_Create;
  2599.     oRace.oFunc.pevent = Race;
  2600.  
  2601.     // Init pause dialog
  2602.     Dialog_Pause_InitMembers();
  2603. }
  2604.  
  2605. func void RaceEnd_MessageBoxCallback(i32x _iResult)
  2606. {
  2607.     // debug : special demo
  2608.     if(G_iDemoVersion)
  2609.     {
  2610.         ExitNow();
  2611.     }
  2612.  
  2613.  // load page news
  2614.     Manager_LoadPage(PAGE_ADMIN);
  2615. }
  2616.  
  2617. //----------------------------------------------------------------------------------------------------------------//
  2618. //----------------------------------------------------------------------------------------------------------------//
  2619. //Create inrace joins
  2620. //----------------------------------------------------------------------------------------------------------------//
  2621. //----------------------------------------------------------------------------------------------------------------//
  2622. func void CreateInraceJoins()
  2623. {
  2624.     // make sure we dont create a memory leak
  2625.     DestroyInraceJoins();
  2626.  
  2627.     // Weather
  2628.     oRace.iCurrentFog = Database_GetIntData(QUERY_PRERACE_DATA,"STA_stage.gene_i_weather",ROW_INDEX,0);
  2629.     if(oRace.iCurrentFog>oRace.iNbFogs)
  2630.         oRace.iCurrentFog = oRace.iNbFogs-1;
  2631.     else if(oRace.iCurrentFog<0)
  2632.         oRace.iCurrentFog = 0;
  2633.  
  2634.     //print("CurrentFog:");println(itoa(oRace.iCurrentFog));
  2635.  
  2636.  
  2637.     // Create inrace joins
  2638.     oRaceEvent.m_jEventID        = Join_Constructor(QUERY_PRERACE_DATA,"DYN_event.IDevent");
  2639.     oRaceEvent.m_jCyclistID        = Join_Constructor(QUERY_PRERACE_DATA,"DYN_event.fkIDcyclist");
  2640.     oRaceEvent.m_jEventsString    = Join_Constructor(QUERY_PRERACE_DATA,"DYN_event.gene_sz_event");
  2641.     oRaceEvent.m_jEventsType    = Join_Constructor(QUERY_PRERACE_DATA,"DYN_event.gene_i_type");
  2642.     oRaceEvent.m_jEventsDistance= Join_Constructor(QUERY_PRERACE_DATA,"DYN_event.gene_i_km");
  2643.     
  2644.     g_stInraceJoins.m_iSprint_Name            = Join_Constructor(QUERY_PRERACE_DATA,    "STA_sprint.gene_sz_name");
  2645.     g_stInraceJoins.m_iCyclist_LastName        = Join_Constructor(QUERY_PRERACE_DATA,    "DYN_cyclist.gene_sz_lastname");
  2646.     g_stInraceJoins.m_iCyclist_FirstName    = Join_Constructor(QUERY_PRERACE_DATA,    "DYN_cyclist.gene_sz_firstname");
  2647.     g_stInraceJoins.m_iCyclist_PreRaceIndex = Join_Constructor(QUERY_PRERACE_DATA,    "DYN_cyclist.prerace_i_cyclist");
  2648.     g_stInraceJoins.m_bCyclist_Withdrawal    = Join_Constructor(QUERY_PRERACE_DATA,    "DYN_cyclist.race_b_withdrawal");
  2649.     g_stInraceJoins.m_iCyclist_TeamName        = Join_Constructor(QUERY_PRERACE_DATA,    "DYN_cyclist.fkIDteam.DYN_team.gene_sz_name");
  2650.     g_stInraceJoins.m_iCyclist_TeamIDName    = Join_Constructor(QUERY_PRERACE_DATA,    "DYN_team.gene_sz_name");
  2651.     g_stInraceJoins.m_jTeam_szAbrev            = Join_Constructor(QUERY_PRERACE_DATA,    "DYN_team.gene_sz_abbreviation");
  2652.     g_stInraceJoins.m_jTeam_iId                = Join_Constructor(QUERY_PRERACE_DATA,    "DYN_team.IDteam");
  2653.     g_stInraceJoins.m_iStage_NameID            = Join_Constructor(QUERY_PRERACE_DATA,    "STA_stage.gene_strID_stage_name");
  2654.     g_stInraceJoins.m_iCyclist_TeamId        = Join_Constructor(QUERY_PRERACE_DATA,    "DYN_cyclist.fkIDteam");
  2655.  
  2656.     // Create palmares subset
  2657.     // Create a subset to store sorting data
  2658.     DatabaseSubset_Create( TEMP_DATABASE, QUERY_PRERACE_DATA);
  2659.     Database_AddTables(    TEMP_DATABASE, 1);
  2660.     Table_SetName( TEMP_DATABASE, 0, "DYN_palmares");
  2661.     TableSubset_SelectColumns( TEMP_DATABASE, 0, "*");
  2662.  
  2663.     g_stInraceJoins.m_iPalmares_iCyclistId    = Join_Constructor(TEMP_DATABASE,    "DYN_palmares.fkIDcyclist");
  2664.     g_stInraceJoins.m_iPalmares_iClassId    = Join_Constructor(TEMP_DATABASE,    "DYN_palmares.fkIDclassification");
  2665.     g_stInraceJoins.m_iPalmares_fValue        = Join_Constructor(TEMP_DATABASE,    "DYN_palmares.gene_f_value");
  2666.  
  2667.     // Jerseys
  2668.     g_stInraceJoins.m_iPalmares_iClassCriterium        = Join_Constructor(QUERY_PRERACE_DATA,    "STA_classification.fkIDcriterium_classification.ALG_criterium_classification.gene_i_type");
  2669.     g_stInraceJoins.m_iPalmares_iClassJerseyDesc    = Join_Constructor(QUERY_PRERACE_DATA,    "STA_classification.gene_sz_jersey_description");
  2670.     g_stInraceJoins.m_iPalmares_iClassJerseyColor    = Join_Constructor(QUERY_PRERACE_DATA,    "STA_classification.game_ilist_RGB");
  2671.  
  2672.     
  2673.     
  2674.     Table_Sort(QUERY_PRERACE_DATA,"DYN_cyclist","prerace_i_cyclist",1);
  2675.     Table_Sort(QUERY_PRERACE_DATA,"STA_sprint","gene_f_km",1);
  2676. }
  2677.  
  2678. //----------------------------------------------------------------------------------------------------------------//
  2679. //----------------------------------------------------------------------------------------------------------------//
  2680. //Destroy inrace joins
  2681. //----------------------------------------------------------------------------------------------------------------//
  2682. //----------------------------------------------------------------------------------------------------------------//
  2683. func void DestroyInraceJoins()
  2684. {
  2685.     // Delete inrace join
  2686.     if (oRaceEvent.m_jEventID)
  2687.     {
  2688.         Join_Destructor(oRaceEvent.m_jEventID);
  2689.         Join_Destructor(oRaceEvent.m_jCyclistID);
  2690.         Join_Destructor(oRaceEvent.m_jEventsString);
  2691.         Join_Destructor(oRaceEvent.m_jEventsType);
  2692.         Join_Destructor(oRaceEvent.m_jEventsDistance);
  2693.         
  2694.         oRaceEvent.m_jEventID = 0;
  2695.         oRaceEvent.m_jCyclistID = 0;
  2696.         oRaceEvent.m_jEventsString = 0;
  2697.         oRaceEvent.m_jEventsType = 0;
  2698.  
  2699.         Join_Destructor(g_stInraceJoins.m_iSprint_Name);
  2700.         Join_Destructor(g_stInraceJoins.m_iCyclist_LastName);
  2701.         Join_Destructor(g_stInraceJoins.m_iCyclist_FirstName);
  2702.         Join_Destructor(g_stInraceJoins.m_iCyclist_PreRaceIndex);
  2703.         Join_Destructor(g_stInraceJoins.m_bCyclist_Withdrawal);
  2704.         Join_Destructor(g_stInraceJoins.m_iCyclist_TeamName);
  2705.         Join_Destructor(g_stInraceJoins.m_iStage_NameID);
  2706.         Join_Destructor(g_stInraceJoins.m_iCyclist_TeamIDName);
  2707.         Join_Destructor(g_stInraceJoins.m_jTeam_szAbrev);
  2708.         Join_Destructor(g_stInraceJoins.m_jTeam_iId);
  2709.         Join_Destructor(g_stInraceJoins.m_iCyclist_TeamId);
  2710.  
  2711.         Join_Destructor(g_stInraceJoins.m_iPalmares_iCyclistId);
  2712.         Join_Destructor(g_stInraceJoins.m_iPalmares_iClassId);
  2713.         Join_Destructor(g_stInraceJoins.m_iPalmares_fValue);
  2714.         Join_Destructor(g_stInraceJoins.m_iPalmares_iClassJerseyDesc);
  2715.         Join_Destructor(g_stInraceJoins.m_iPalmares_iClassJerseyColor);
  2716.         Join_Destructor(g_stInraceJoins.m_iPalmares_iClassCriterium);
  2717.         
  2718.  
  2719.         g_stInraceJoins.m_iCyclist_PreRaceIndex = 0;
  2720.         g_stInraceJoins.m_iSprint_Name = 0;
  2721.         g_stInraceJoins.m_iCyclist_LastName = 0;
  2722.         g_stInraceJoins.m_iCyclist_FirstName = 0;
  2723.         g_stInraceJoins.m_bCyclist_Withdrawal = 0;
  2724.         g_stInraceJoins.m_iCyclist_TeamName = 0;
  2725.         g_stInraceJoins.m_iStage_NameID = 0;
  2726.         g_stInraceJoins.m_iCyclist_TeamIDName = 0;
  2727.         g_stInraceJoins.m_jTeam_szAbrev = 0;
  2728.         g_stInraceJoins.m_iCyclist_TeamId = 0;
  2729.         g_stInraceJoins.m_jTeam_iId = 0;
  2730.     
  2731.         g_stInraceJoins.m_iPalmares_iClassCriterium = 0;
  2732.         g_stInraceJoins.m_iPalmares_iCyclistId = 0;
  2733.         g_stInraceJoins.m_iPalmares_iClassId = 0;
  2734.         g_stInraceJoins.m_iPalmares_fValue = 0;
  2735.         g_stInraceJoins.m_iPalmares_iClassJerseyDesc = 0;
  2736.         g_stInraceJoins.m_iPalmares_iClassJerseyColor = 0;
  2737.     }
  2738. }
  2739.  
  2740. //----------------------------------------------------------------------------------------------------------------//
  2741. //----------------------------------------------------------------------------------------------------------------//
  2742. //Dialog_Pause Create func
  2743. //----------------------------------------------------------------------------------------------------------------//
  2744. //----------------------------------------------------------------------------------------------------------------//
  2745. func void Dialog_Pause_Create ()
  2746. {
  2747.     var i32x iID;
  2748.  
  2749.     // Get dialbox context
  2750.     if(oDialog_Pause.cComponent != g_poNullComponent)
  2751.     {
  2752.         print("Warning : Old Loading dialbox not deleted !\n");
  2753.     }
  2754.     oDialog_Pause.cComponent = GetParserComponent();    
  2755.  
  2756.     SetComponentNumber(5);
  2757.  
  2758.     // background
  2759.     iID=Init_LibObject_FilledCadre(tCadreDialbox,400,150);
  2760.     oDialog_Pause.iBackgroundID=iID;
  2761.     SetEvents(iID,GUI_NoEvent);
  2762.  
  2763.     // text
  2764.     iID=InitContainer(tFontArial);
  2765.     SetComponentSize(iID,280,100);
  2766.     SetContainerText(iID,GetLocalizedFromGMKey(447)); // Pause
  2767.  
  2768.     SetComponentPosition(iID,70,40);
  2769.     SetEvents(iID,GUI_NoEvent);
  2770.     oDialog_Pause.iMessageTextID=iID;
  2771.  
  2772.     // Hour picto background
  2773.     iID=InitContainer(t_bckpicto_hour);
  2774.     SetComponentPosition(iID,20,40);
  2775.  
  2776.     iID=InitContainer(t_picto_hour);
  2777.     SetComponentPosition(iID,20,40);
  2778.     SetContainerRotationCenter(iID,16,16);
  2779.     SetEvents(iID,GUI_NoEvent);
  2780.     oDialog_Pause.iPictoID=iID;
  2781.  
  2782.     //Parameters    :    Param(0) Component ID
  2783.     //Parameters    :    Param(1-11) i32x _x,i32x _y,f32x _fw,f32x _fh,f32x _fOffset,f32x _fAngle,ui8x _r,ui8x _g,ui8x _b,ui8x _a,f32x _fFrameOffset
  2784.     oDialog_Pause.m_fHour[0] = AddFrame(iID, 0, 0, 1.0, 1.0, 0.0, 0.0, 0, 0, 0, 0, 0.0);
  2785.     oDialog_Pause.m_fHour[1] = AddFrame(iID, 0, 0, 1.0, 1.0, 0.0, 0.0, 0, 0, 0, 0, 0.5);
  2786.     SetAnimationFlags(iID,MSL_Rotation);
  2787.     SetAnimationSpeed(iID,0.01);
  2788.     GotoFirstFrame(iID);
  2789.     SetNextFrame(iID,oDialog_Pause.m_fHour[0]);
  2790.     StartAnimation(iID);
  2791.  
  2792.     // resize the panel*/
  2793.     SetObjectSize(400,150);
  2794. }
  2795.  
  2796. //----------------------------------------------------------------------------------------------------------------//
  2797. //----------------------------------------------------------------------------------------------------------------//
  2798. // Dialog_Pause Event func
  2799. //----------------------------------------------------------------------------------------------------------------//
  2800. //----------------------------------------------------------------------------------------------------------------//
  2801. func i32x Dialog_Pause_Event (i32x _iComponentID, i32x _iEvent)
  2802. {
  2803.     if(_iComponentID==-1)
  2804.     {
  2805.         if(_iEvent == GUI_COMPONENT_DESTRUCTOR)
  2806.         {
  2807.             // Raz context
  2808.             oDialog_Pause.cComponent = g_poNullComponent;
  2809.         }
  2810.     }
  2811.     return 1;
  2812. }
  2813.  
  2814. //----------------------------------------------------------------------------------------------------------------//
  2815. //----------------------------------------------------------------------------------------------------------------//
  2816. //Constructor
  2817. //----------------------------------------------------------------------------------------------------------------//
  2818. //----------------------------------------------------------------------------------------------------------------//
  2819. func i32x Dialog_Pause_Constructor ()
  2820. {
  2821.     oDialog_Pause.iDialogID=InitObject(oDialog_Pause.szName,oDialog_Pause.oFunc.pcreate,oDialog_Pause.oFunc.pevent);
  2822.     SetStackEvents(oDialog_Pause.iDialogID,GUI_Destroy);
  2823.     return oDialog_Pause.iDialogID;
  2824. }
  2825.  
  2826. //----------------------------------------------------------------------------------------------------------------//
  2827. //----------------------------------------------------------------------------------------------------------------//
  2828. //Destructor
  2829. //----------------------------------------------------------------------------------------------------------------//
  2830. //----------------------------------------------------------------------------------------------------------------//
  2831. func void Dialog_Pause_Destructor ()
  2832. {
  2833.     // delete the dialog
  2834.     DeleteComponent(oDialog_Pause.iDialogID);
  2835.     oDialog_Pause.iDialogID = ID_NOT_CREATED;
  2836.     oDialog_Pause.iMessageTextID = ID_NOT_CREATED;
  2837. }
  2838.  
  2839. //----------------------------------------------------------------------------------------------------------------//
  2840. //----------------------------------------------------------------------------------------------------------------//
  2841. //Dialog_Pause Init member
  2842. //----------------------------------------------------------------------------------------------------------------//
  2843. //----------------------------------------------------------------------------------------------------------------//
  2844. func void Dialog_Pause_InitMembers ()
  2845. {
  2846.     oDialog_Pause.szName        = "Dialog_Pause";
  2847.     oDialog_Pause.oFunc.pcreate    = Dialog_Pause_Create;
  2848.     oDialog_Pause.oFunc.pevent    = Dialog_Pause_Event;
  2849.  
  2850. }
  2851.  
  2852.