瀏覽代碼

FREE_SetupDifficulty bugfix

DESKTOP-AB9OQPJ\RED-10 3 年之前
父節點
當前提交
36be83ff7d
共有 2 個文件被更改,包括 125 次插入73 次删除
  1. 124 72
      jni/FREE.cpp
  2. 1 1
      jni/TFreeControl.h

+ 124 - 72
jni/FREE.cpp

@@ -1,5 +1,5 @@
 #include "FREE.h"
-#include "memctrl.h"
+
 #include "CBall.h"
 #include "CFTTPObject.h"
 #include "CFTTPPBox.h"
@@ -9,12 +9,13 @@
 #include "CFTTPPSphere.h"
 #include "CFTTPhysics.h"
 #include "CModelManager.h"
+#include "CPlayerManager.h"
 #include "fpoint.h"
+#include "memctrl.h"
 #include "sub.h"
-#include "CPlayerManager.h"
 // FREE_tInfo  0x1D20
 // FREE_tGoal  0x7634
-
+TFreeGoal FREE_tGoal;
 TFreeInfo FREE_tInfo;
 CFTTModel *FREE_pStarModel;
 int FREE_iPropWeather;
@@ -64,9 +65,8 @@ int FREE_PassIsLowKick(TFreeControl *, TPoint3D *, TPoint3D *, int) {
   return 0;
 }
 //-------------------------------------------------------------------------------------------------
-// 001D3FA8 
+// 001D3FA8
 void FREE_ControlGetKickLimits(CPlayer *player0, int *pi1, int *pi2, int *pi3) {
-   
   int *var_58 = pi1;
   int *var_54 = pi2;
   int *var_50 = pi3;
@@ -232,8 +232,62 @@ void FREE_Shutdown() {}
 // 001D41B0
 void FREE_InitGoal(int, bool, bool, bool) {}
 //-------------------------------------------------------------------------------------------------
-// 001D4318
-void FREE_SetupDifficulty() {}
+// 001D4318 //^_-
+//单元测试等级:目测游戏表现
+//测试内容:启动游戏到第1关传球射门
+//测试结果: 游戏表现正常无崩溃且无明显变化,检测到日志输出
+//测试分支: 001D4318
+void FREE_SetupDifficulty() {
+  /*
+   * 描述:此处自己的汇编变量赋值上顺序有不同,多种尝试,不太容易完全一致
+   */
+  FREE_tInfo.field_1C9C.m_iCPUPlayerCloseDownCount_1CF8 =
+      FREE_tGoal.m_iCPUPlayerCloseDownCount_747C;
+  FREE_tInfo.field_1C9C.m_fCPUCloseDownDist_1CFC =
+      FREE_tGoal.m_fCPUCloseDownDist_7480;
+  FREE_tInfo.field_1C9C.m_iCPUKickResponseTime_1D18 =
+      FREE_tGoal.m_iCPUKickResponseTime_749C;
+  FREE_tInfo.field_1C9C.m_iCPUMoveResponseTime_1D1C =
+      FREE_tGoal.m_iCPUMoveResponseTime_74A0;
+  FREE_tInfo.field_1C9C.m_iCPUGKRating_1D00 = FREE_tGoal.m_iCPUGKRating_7484;
+  //注意!!!!!这里的数据符号不对 注意更新 FREE_tGoal.m_fCPUGKSaveAlwaysDistance_7488为float
+  FREE_tInfo.field_1C9C.m_fCPUGKSaveAlwaysDistance_1D04 =
+      FREE_tGoal.m_fCPUGKSaveAlwaysDistance_7488;
+  FREE_tInfo.field_1C9C.m_iCPUGKSaveResponseTime_1D08 =
+      FREE_tGoal.m_iCPUGKSaveResponseTime_748C;
+  FREE_tInfo.field_1C9C.m_fCPUGKSaveSpeed_1D0C =
+      FREE_tGoal.m_fCPUGKSaveSpeed_7490;
+  FREE_tInfo.field_1C9C.m_fCPUGKSaveDistance_1D10 =
+      FREE_tGoal.m_fCPUGKSaveDistance_7494;
+
+  uchar r5_c = FREE_tInfo.field_1C9C.field_1CF6;
+  FREE_tInfo.field_1C9C.m_iCPUGKPosResponseTime_1D14 =
+      FREE_tGoal.m_iCPUGKPosResponseTime_7498;
+  // 001D43B6
+  if (r5_c != 0) {
+    // 001D43B8
+    // float s0_f = 2.8;
+    FREE_tInfo.field_1C9C.m_iCPUGKRating_1D00 =
+        FREE_tGoal.m_iCPUGKRating_7484 - 5;
+    FREE_tInfo.field_1C9C.m_iCPUGKPosResponseTime_1D14 =
+        FREE_tGoal.m_iCPUGKPosResponseTime_7498 + 4;
+    FREE_tInfo.field_1C9C.m_fCPUGKSaveAlwaysDistance_1D04 =
+        FREE_tGoal.m_fCPUGKSaveAlwaysDistance_7488 -0.200000003f;
+    
+    
+    // 001D43E6
+    if ((float)FREE_tGoal.m_fCPUGKSaveDistance_7494 - 0.200000003f > 2.8f) {
+      // 001D43FA
+      FREE_tInfo.field_1C9C.m_fCPUGKSaveDistance_1D10 =
+          (float)FREE_tGoal.m_fCPUGKSaveDistance_7494 - 0.200000003f;
+    } else
+      FREE_tInfo.field_1C9C.m_fCPUGKSaveDistance_1D10 = 2.8f;
+    FREE_tInfo.field_1C9C.m_fCPUGKSaveSpeed_1D0C =
+        FREE_tGoal.m_fCPUGKSaveSpeed_7490 -5.0f;
+    
+  }
+  // locret_1D4410
+}
 //-------------------------------------------------------------------------------------------------
 // 001D4424
 void FREE_Initialise() {}
@@ -405,8 +459,7 @@ void FREE_ClipPathBounds(TPoint3D *, TPoint3D *, int, int, int, int) {}
 // }
 //-------------------------------------------------------------------------------------------------
 // 001D58B4
-void FREE_StoreRewindState() {
-  tGame.mTLogic_6678.field_8=rand()%10;}
+void FREE_StoreRewindState() { tGame.mTLogic_6678.field_8 = rand() % 10; }
 //-------------------------------------------------------------------------------------------------
 // 001D5A3E
 void FREE_UpdateRewindState() {}
@@ -425,16 +478,15 @@ void FREE_ClipPathBounds(TPoint *, TPoint *, int, int, int, int) {}
 //-------------------------------------------------------------------------------------------------
 // 001D656C
 void FREE_IdleProcess() {
-  tGame.mTLogic_6678.field_8=1;
+  tGame.mTLogic_6678.field_8 = 1;
   LOGE("FREE_IdleProcess");
 }
 //-------------------------------------------------------------------------------------------------
 // 001D66F0
 void FREE_SetupKick(TFreeControl *, TPoint3D *) {}
 
-void COUNTER_UpdateGenericCounters(void)
-{
-  LOGE("COUNTER_UpdateGenericCountersrand=%x",rand());
+void COUNTER_UpdateGenericCounters(void) {
+  LOGE("COUNTER_UpdateGenericCountersrand=%x", rand());
 }
 //-------------------------------------------------------------------------------------------------
 // 001D6778 //^_-
@@ -442,12 +494,11 @@ void COUNTER_UpdateGenericCounters(void)
 //测试内容:启动游戏到第5关传球射门
 //测试结果: 修复后游戏表现正常
 void FREE_LogicProcess() {
-
   tGame.mTLogic_6678.field_AC = cBall.ballPosPrev_4.point_0.dx_0;
   tGame.mTLogic_6678.field_B0 = cBall.ballPosPrev_4.point_0.dy_4;
-  
+
   // 001D679E
-  if (tGame.mTLogic_6678.field_8 >2&&tGame.mTLogic_6678.field_8<5) {
+  if (tGame.mTLogic_6678.field_8 > 2 && tGame.mTLogic_6678.field_8 < 5) {
     // 001D67A2
     FREE_IdleProcess();
   } else {
@@ -649,12 +700,12 @@ bool FREE_ReadXML(TFreeGoal *, char *) { return 0; }
 // 001DCA14
 void FREE_ReadXMLLevel(TFreeGoal *, CFTTXmlReaderNode) {}
 //-------------------------------------------------------------------------------------------------
-// 00169A80 ^_-  
+// 00169A80 ^_-
 //单元测试等级: 游戏运行正常
 //单元测试内容: 1-10关
 //单元测试结果: 正常
 void PhysicsTest() {
-  LOGE("PhysicsTest_0");//OK
+  LOGE("PhysicsTest_0");  // OK
   fpointQ<PointType_18> fpointq_sp240;
   fpointq_sp240.field_0 = 0;
   fpointq_sp240.field_4 = 0;
@@ -693,8 +744,8 @@ void PhysicsTest() {
   fpoint3_sp230.z_8 = 0;
   fpoint_sp23c.var_0 = 0x8000;
   // check 传参是否都是用了栈
-  CFTTPPSphere *r0_psphere =
-      new CFTTPPSphere(fpoint_sp23c, fpoint3_sp230, fpointQ_sp220);//这里头文件更新
+  CFTTPPSphere *r0_psphere = new CFTTPPSphere(fpoint_sp23c, fpoint3_sp230,
+                                              fpointQ_sp220);  //这里头文件更新
   // 00169B60
   r6_pobject->field_3C = 0x8000;
   r0_psphere->field_64 = 0x8000;
@@ -991,24 +1042,24 @@ void PhysicsTest() {
               FREE_tInfo.filed_0.pFREE_tGoal_1818->m_tFreeProp_74F4[r2_i]
                   .m_iType_C,
               3, fpoint3_spdc, fpointQ_spcc);
-          //0016A1B0
-          r0_pobject->field_34=0;
-          r0_pobject->field_38=0;
-          r0_pobject->field_3C=0x70000;
-          r0_pobject->field_40=0x30000;
-          r0_pobject->field_44=0x4000;
-          r0_pobject->field_A0=0x18;
-          r0_pobject->pprimitive_98[r0_pobject->uc_9C++]=pbox_sp38;
-          pbox_sp38->filed_4=r0_pobject;
+          // 0016A1B0
+          r0_pobject->field_34 = 0;
+          r0_pobject->field_38 = 0;
+          r0_pobject->field_3C = 0x70000;
+          r0_pobject->field_40 = 0x30000;
+          r0_pobject->field_44 = 0x4000;
+          r0_pobject->field_A0 = 0x18;
+          r0_pobject->pprimitive_98[r0_pobject->uc_9C++] = pbox_sp38;
+          pbox_sp38->filed_4 = r0_pobject;
 
-          r0_pobject->pprimitive_98[r0_pobject->uc_9C++]=r4_pbox;
-          r4_pbox->filed_4=r0_pobject;
+          r0_pobject->pprimitive_98[r0_pobject->uc_9C++] = r4_pbox;
+          r4_pbox->filed_4 = r0_pobject;
 
-          r0_pobject->pprimitive_98[r0_pobject->uc_9C++]=r6_pbox;
-          r6_pbox->filed_4=r0_pobject;
+          r0_pobject->pprimitive_98[r0_pobject->uc_9C++] = r6_pbox;
+          r6_pbox->filed_4 = r0_pobject;
 
-
-          physics_sp218.ppobject_0[physics_sp218.object_counts_4++]=r0_pobject;
+          physics_sp218.ppobject_0[physics_sp218.object_counts_4++] =
+              r0_pobject;
 
           break;
         }
@@ -1124,50 +1175,51 @@ void PhysicsTest() {
     }
   }
   // loc_16A232
-  physics_sp218.ppobject_0[physics_sp218.object_counts_4++]=  r6_pobject;
-  if(physics_sp218.Process()){
-    //0016A24E
-    //sp18=cBall
+  physics_sp218.ppobject_0[physics_sp218.object_counts_4++] = r6_pobject;
+  if (physics_sp218.Process()) {
+    // 0016A24E
+    // sp18=cBall
     LOGE("PhysicsTest_1");
-    cBall.ballPosPrev_4.point_0.dx_0=r6_pobject->fpoint3_0.x_0/(-8);//这里fpoint3_0猜测可能为ballPosPrev_4
-    cBall.ballPosPrev_4.point_0.dy_4=r6_pobject->fpoint3_0.z_8/8;
-    cBall.ballPosPrev_4.dz_8=r6_pobject->fpoint3_0.y_4/8;
+    cBall.ballPosPrev_4.point_0.dx_0 =
+        r6_pobject->fpoint3_0.x_0 /
+        (-8);  //这里fpoint3_0猜测可能为ballPosPrev_4
+    cBall.ballPosPrev_4.point_0.dy_4 = r6_pobject->fpoint3_0.z_8 / 8;
+    cBall.ballPosPrev_4.dz_8 = r6_pobject->fpoint3_0.y_4 / 8;
 
-    cBall.ballMovePrev_10.point_0.dx_0=r6_pobject->fpoint3_1C.x_0/(-8);
-    cBall.ballMovePrev_10.point_0.dy_4=r6_pobject->fpoint3_1C.z_8/8;
-    cBall.ballMovePrev_10.dz_8=r6_pobject->fpoint3_1C.y_4/8;
+    cBall.ballMovePrev_10.point_0.dx_0 = r6_pobject->fpoint3_1C.x_0 / (-8);
+    cBall.ballMovePrev_10.point_0.dy_4 = r6_pobject->fpoint3_1C.z_8 / 8;
+    cBall.ballMovePrev_10.dz_8 = r6_pobject->fpoint3_1C.y_4 / 8;
     fpointQ<PointType_18> fpointQ_sp1b0;
-    sub_16A88C(fpointQ_sp1b0,r6_pobject->fpointQ_C);
-    //check 除法
-     //0016A2AA
-    cBall.quat_68.d1_0=fpointQ_sp1b0.field_0/64;
-    cBall.quat_68.d2_4=fpointQ_sp1b0.field_4/64;
-    cBall.quat_68.d3_8=fpointQ_sp1b0.field_8/64;
-    cBall.quat_68.d4_C=fpointQ_sp1b0.field_C/64;
-    //check
-    cBall.point3D_1C.point_0.dx_0= r6_pobject->fpoint3_28.x_0/(-101);
-    cBall.point3D_1C.point_0.dy_4= r6_pobject->fpoint3_28.z_8/101;
-    cBall.point3D_1C.dz_8= r6_pobject->fpoint3_28.y_4/101;
-    //loc_16A344
-    for(int r5_i=0;r5_i<physics_sp218.object_counts_4;r5_i++){
-      //loc_16A30C
-      if(physics_sp218.ppobject_0[r5_i]->field_9E){
-        if(physics_sp218.ppobject_0[r5_i]->field_90!=EFreePropType_3){
-            if(FREE_tInfo.filed_0.ugamestatus_1828<=8){
-              //check
-              if((1<<FREE_tInfo.filed_0.ugamestatus_1828)&0x190){
-                LOGE("PhysicsTest_2");
-                tGame.field_6C98=0;
-                tGame.mTLogic_6678.freeproptype_74= physics_sp218.ppobject_0[r5_i]->field_90;
-              }
+    sub_16A88C(fpointQ_sp1b0, r6_pobject->fpointQ_C);
+    // check 除法
+    // 0016A2AA
+    cBall.quat_68.d1_0 = fpointQ_sp1b0.field_0 / 64;
+    cBall.quat_68.d2_4 = fpointQ_sp1b0.field_4 / 64;
+    cBall.quat_68.d3_8 = fpointQ_sp1b0.field_8 / 64;
+    cBall.quat_68.d4_C = fpointQ_sp1b0.field_C / 64;
+    // check
+    cBall.point3D_1C.point_0.dx_0 = r6_pobject->fpoint3_28.x_0 / (-101);
+    cBall.point3D_1C.point_0.dy_4 = r6_pobject->fpoint3_28.z_8 / 101;
+    cBall.point3D_1C.dz_8 = r6_pobject->fpoint3_28.y_4 / 101;
+    // loc_16A344
+    for (int r5_i = 0; r5_i < physics_sp218.object_counts_4; r5_i++) {
+      // loc_16A30C
+      if (physics_sp218.ppobject_0[r5_i]->field_9E) {
+        if (physics_sp218.ppobject_0[r5_i]->field_90 != EFreePropType_3) {
+          if (FREE_tInfo.filed_0.ugamestatus_1828 <= 8) {
+            // check
+            if ((1 << FREE_tInfo.filed_0.ugamestatus_1828) & 0x190) {
+              LOGE("PhysicsTest_2");
+              tGame.field_6C98 = 0;
+              tGame.mTLogic_6678.freeproptype_74 =
+                  physics_sp218.ppobject_0[r5_i]->field_90;
             }
+          }
         }
       }
     }
-   
   }
-  //loc_16A348
-  delete [] pfpoint3_sp34;
-
+  // loc_16A348
+  delete[] pfpoint3_sp34;
 }
 //-------------------------------------------------------------------------------------------------

+ 1 - 1
jni/TFreeControl.h

@@ -87,7 +87,7 @@ struct TFreeGoal {
   int         m_iCPUPlayerCloseDownCount_747C;
   float       m_fCPUCloseDownDist_7480;
   int         m_iCPUGKRating_7484;
-  int         m_fCPUGKSaveAlwaysDistance_7488;
+  float         m_fCPUGKSaveAlwaysDistance_7488;
   int         m_iCPUGKSaveResponseTime_748C;
   float       m_fCPUGKSaveSpeed_7490;
   float       m_fCPUGKSaveDistance_7494;