Mercurial > mm7
comparison Party.cpp @ 82:1faa29fd4c2d
many type, memory, boundary fixes
author | zipi |
---|---|
date | Sun, 03 Feb 2013 23:37:17 +0000 |
parents | 9c0607679772 |
children | be45fc285970 |
comparison
equal
deleted
inserted
replaced
81:377535d6e366 | 82:1faa29fd4c2d |
---|---|
868 } | 868 } |
869 | 869 |
870 //----- (004909F4) -------------------------------------------------------- | 870 //----- (004909F4) -------------------------------------------------------- |
871 void Party::_4909F4() | 871 void Party::_4909F4() |
872 { | 872 { |
873 char *v1; // esi@2 | 873 Player *v1; // esi@2 |
874 unsigned int v2; // eax@3 | 874 unsigned int v2; // eax@3 |
875 __int16 v3; // cx@5 | 875 __int16 v3; // cx@5 |
876 int v4; // edx@27 | 876 int v4; // edx@27 |
877 signed int v5; // eax@52 | 877 signed int v5; // eax@52 |
878 PlayerFrame *v6; // edx@53 | 878 PlayerFrame *v6; // edx@53 |
879 char *v7; // esi@60 | 879 NPCData *v7; // esi@60 |
880 signed int v8; // ebp@61 | 880 signed int v8; // ebp@61 |
881 int v9; // ebx@62 | 881 int v9; // ebx@62 |
882 unsigned int v10; // edi@62 | 882 unsigned int v10; // edi@62 |
883 signed int v11; // [sp+0h] [bp-4h]@2 | 883 signed int v11; // [sp+0h] [bp-4h]@2 |
884 | 884 |
885 if ( dword_A75070 != stru_51076C.field_8 ) | 885 if ( dword_A75070 != stru_51076C.field_8 ) |
886 { | 886 { |
887 dword_A75070 = stru_51076C.field_8; | 887 dword_A75070 = stru_51076C.field_8; |
888 v1 = (char *)&this->pPlayers[0].uExpressionID; | 888 v1 = this->pPlayers;//(char *)&this->pPlayers[0].uExpressionID; |
889 v11 = 4; | 889 v11 = 4; |
890 do | 890 do |
891 { | 891 { |
892 v2 = ((Player *)(v1 - 6812))->GetMajorConditionIdx(); | 892 v2 = ((Player *)(v1 - 6812))->GetMajorConditionIdx(); |
893 if ( v2 == 18 || v2 == 17 ) | 893 if ( v2 == 18 || v2 == 17 ) |
894 { | 894 { |
895 *((short *)v1 + 1) += LOWORD(pMiscTimer->uTimeElapsed); | 895 v1->uExpressionTimePassed += LOWORD(pMiscTimer->uTimeElapsed); |
896 if ( *((short *)v1 + 1) >= *((short *)v1 + 2) ) | 896 if ( (unsigned __int16)v1->uExpressionTimePassed >= v1->uExpressionTimeLength ) |
897 { | 897 { |
898 if ( *(short *)v1 != 1 || rand() % 5 ) | 898 if ( v1->uExpressionID != 1 || rand() % 5 ) |
899 { | 899 { |
900 *((short *)v1 + 1) = 0; | 900 v1->uExpressionTimePassed = 0; |
901 *(short *)v1 = 1; | 901 v1->uExpressionID = 1; |
902 *((short *)v1 + 2) = rand() % 256 + 32; | 902 v1->uExpressionTimeLength = rand() % 256 + 32; |
903 } | 903 } |
904 else | 904 else |
905 { | 905 { |
906 v4 = rand() % 100; | 906 v4 = rand() % 100; |
907 if ( v4 >= 25 ) | 907 if ( v4 >= 25 ) |
925 if ( v4 >= 76 ) | 925 if ( v4 >= 76 ) |
926 { | 926 { |
927 if ( v4 >= 82 ) | 927 if ( v4 >= 82 ) |
928 { | 928 { |
929 if ( v4 >= 88 ) | 929 if ( v4 >= 88 ) |
930 *(short *)v1 = (v4 >= 94) + 29; | 930 v1->uExpressionID = (v4 >= 94) + 29; |
931 else | 931 else |
932 *(short *)v1 = 57; | 932 v1->uExpressionID = 57; |
933 } | 933 } |
934 else | 934 else |
935 { | 935 { |
936 *(short *)v1 = 56; | 936 v1->uExpressionID = 56; |
937 } | 937 } |
938 } | 938 } |
939 else | 939 else |
940 { | 940 { |
941 *(short *)v1 = 55; | 941 v1->uExpressionID = 55; |
942 } | 942 } |
943 } | 943 } |
944 else | 944 else |
945 { | 945 { |
946 *(short *)v1 = 54; | 946 v1->uExpressionID = 54; |
947 } | 947 } |
948 } | 948 } |
949 else | 949 else |
950 { | 950 { |
951 *(short *)v1 = 20; | 951 v1->uExpressionID = 20; |
952 } | 952 } |
953 } | 953 } |
954 else | 954 else |
955 { | 955 { |
956 *(short *)v1 = 19; | 956 v1->uExpressionID = 19; |
957 } | 957 } |
958 } | 958 } |
959 else | 959 else |
960 { | 960 { |
961 *(short *)v1 = 18; | 961 v1->uExpressionID = 18; |
962 } | 962 } |
963 } | 963 } |
964 else | 964 else |
965 { | 965 { |
966 *(short *)v1 = 17; | 966 v1->uExpressionID = 17; |
967 } | 967 } |
968 } | 968 } |
969 else | 969 else |
970 { | 970 { |
971 *(short *)v1 = 16; | 971 v1->uExpressionID = 16; |
972 } | 972 } |
973 } | 973 } |
974 else | 974 else |
975 { | 975 { |
976 *(short *)v1 = 15; | 976 v1->uExpressionID = 15; |
977 } | 977 } |
978 } | 978 } |
979 else | 979 else |
980 { | 980 { |
981 *(short *)v1 = 14; | 981 v1->uExpressionID = 14; |
982 } | 982 } |
983 } | 983 } |
984 else | 984 else |
985 { | 985 { |
986 *(short *)v1 = 13; | 986 v1->uExpressionID = 13; |
987 } | 987 } |
988 v5 = 0; | 988 v5 = 0; |
989 *((short *)v1 + 1) = 0; | 989 v1->uExpressionTimePassed = 0; |
990 if ( (signed int)pPlayerFrameTable->uNumFrames <= 0 ) | 990 if ( (signed int)pPlayerFrameTable->uNumFrames <= 0 ) |
991 { | 991 { |
992 LABEL_56: | 992 LABEL_56: |
993 v5 = 0; | 993 v5 = 0; |
994 } | 994 } |
995 else | 995 else |
996 { | 996 { |
997 v6 = pPlayerFrameTable->pFrames; | 997 v6 = pPlayerFrameTable->pFrames; |
998 while ( v6->uSequenceID != *(short *)v1 ) | 998 while ( v6->uSequenceID != v1->uExpressionID ) |
999 { | 999 { |
1000 ++v5; | 1000 ++v5; |
1001 ++v6; | 1001 ++v6; |
1002 if ( v5 >= (signed int)pPlayerFrameTable->uNumFrames ) | 1002 if ( v5 >= (signed int)pPlayerFrameTable->uNumFrames ) |
1003 goto LABEL_56; | 1003 goto LABEL_56; |
1004 } | 1004 } |
1005 } | 1005 } |
1006 *((short *)v1 + 2) = 8 * pPlayerFrameTable->pFrames[v5].uAnimLength; | 1006 v1->uExpressionTimeLength = 8 * pPlayerFrameTable->pFrames[v5].uAnimLength; |
1007 } | 1007 } |
1008 } | 1008 } |
1009 } | 1009 } |
1010 else | 1010 else |
1011 { | 1011 { |
1012 v3 = *(short *)v1; | 1012 v3 = v1->uExpressionID; |
1013 if ( *(short *)v1 != 34 && v3 != 35 && v3 != 36 | 1013 if ( v1->uExpressionID != 34 && v3 != 35 && v3 != 36 |
1014 || (signed int)(pMiscTimer->uTimeElapsed + *((short *)v1 + 1)) >= *((short *)v1 + 2) ) | 1014 || (signed int)(pMiscTimer->uTimeElapsed + v1->uExpressionTimePassed) >= v1->uExpressionTimeLength ) |
1015 { | 1015 { |
1016 *((short *)v1 + 2) = 0; | 1016 v1->uExpressionTimeLength = 0; |
1017 *((short *)v1 + 1) = 0; | 1017 v1->uExpressionTimePassed = 0; |
1018 switch ( v2 ) | 1018 switch ( v2 ) |
1019 { | 1019 { |
1020 case 0xEu: | 1020 case 0xEu: |
1021 *(short *)v1 = 98; | 1021 v1->uExpressionID = 98; |
1022 break; | 1022 break; |
1023 case 0xFu: | 1023 case 0xFu: |
1024 *(short *)v1 = 12; | 1024 v1->uExpressionID = 12; |
1025 break; | 1025 break; |
1026 case 0x10u: | 1026 case 0x10u: |
1027 *(short *)v1 = 99; | 1027 v1->uExpressionID = 99; |
1028 break; | 1028 break; |
1029 case 0u: | 1029 case 0u: |
1030 *(short *)v1 = 2; | 1030 v1->uExpressionID = 2; |
1031 break; | 1031 break; |
1032 case 1u: | 1032 case 1u: |
1033 *(short *)v1 = 3; | 1033 v1->uExpressionID = 3; |
1034 break; | 1034 break; |
1035 case 2u: | 1035 case 2u: |
1036 *(short *)v1 = 4; | 1036 v1->uExpressionID = 4; |
1037 break; | 1037 break; |
1038 case 3u: | 1038 case 3u: |
1039 *(short *)v1 = 5; | 1039 v1->uExpressionID = 5; |
1040 break; | 1040 break; |
1041 case 4u: | 1041 case 4u: |
1042 *(short *)v1 = 6; | 1042 v1->uExpressionID = 6; |
1043 break; | 1043 break; |
1044 case 5u: | 1044 case 5u: |
1045 *(short *)v1 = 7; | 1045 v1->uExpressionID = 7; |
1046 break; | 1046 break; |
1047 case 6u: | 1047 case 6u: |
1048 case 8u: | 1048 case 8u: |
1049 case 0xAu: | 1049 case 0xAu: |
1050 *(short *)v1 = 8; | 1050 v1->uExpressionID = 8; |
1051 break; | 1051 break; |
1052 case 7u: | 1052 case 7u: |
1053 case 9u: | 1053 case 9u: |
1054 case 0xBu: | 1054 case 0xBu: |
1055 *(short *)v1 = 9; | 1055 v1->uExpressionID = 9; |
1056 break; | 1056 break; |
1057 case 0xCu: | 1057 case 0xCu: |
1058 *(short *)v1 = 10; | 1058 v1->uExpressionID = 10; |
1059 break; | 1059 break; |
1060 case 0xDu: | 1060 case 0xDu: |
1061 *(short *)v1 = 11; | 1061 v1->uExpressionID = 11; |
1062 break; | 1062 break; |
1063 default: | 1063 default: |
1064 break; | 1064 break; |
1065 } | 1065 } |
1066 } | 1066 } |
1067 else | 1067 else |
1068 { | 1068 { |
1069 *((short *)v1 + 1) += LOWORD(pMiscTimer->uTimeElapsed); | 1069 v1->uExpressionTimePassed += LOWORD(pMiscTimer->uTimeElapsed); |
1070 } | 1070 } |
1071 } | 1071 } |
1072 v1 += 6972; | 1072 ++v1; |
1073 --v11; | 1073 --v11; |
1074 } | 1074 } |
1075 while ( v11 ); | 1075 while ( v11 ); |
1076 v7 = (char *)&pParty->pHirelings[0].evtb; | 1076 v7 = pParty->pHirelings;//(char *)&pParty->pHirelings[0].evtb; |
1077 do | 1077 do |
1078 { | 1078 { |
1079 v8 = *((int *)v7 + 1); | 1079 v8 = v7->evtc; |
1080 if ( v8 ) | 1080 if ( v8 ) |
1081 { | 1081 { |
1082 v9 = *((int *)v7 - 1); | 1082 v9 = v7->bDrawSomeAnim; |
1083 v10 = pMiscTimer->uTimeElapsed + *(int *)v7; | 1083 v10 = pMiscTimer->uTimeElapsed + v7->evtb; |
1084 if ( (signed int)v10 >= v8 ) | 1084 if ( (signed int)v10 >= v8 ) |
1085 { | 1085 { |
1086 v9 = 0; | 1086 v9 = 0; |
1087 v8 = 0; | 1087 v8 = 0; |
1088 v10 = 0; | 1088 v10 = 0; |
1089 memset(v7 - 44, 0, 0x4Cu); | 1089 memset(v7, 0, 0x4Cu); |
1090 pParty->field_709 = 0; | 1090 pParty->field_709 = 0; |
1091 //sub_44A56A();Ritor1: it's temporarily | 1091 //sub_44A56A();Ritor1: it's temporarily |
1092 viewparams->bRedrawGameUI = 1; | 1092 viewparams->bRedrawGameUI = 1; |
1093 } | 1093 } |
1094 *(int *)v7 = v10; | 1094 v7->evtb = v10; |
1095 *((int *)v7 + 1) = v8; | 1095 v7->evtc = v8; |
1096 *((int *)v7 - 1) = v9; | 1096 v7->bDrawSomeAnim = v9; |
1097 } | 1097 } |
1098 v7 += 76; | 1098 ++v7; |
1099 } | 1099 } |
1100 while ( (signed int)v7 < (signed int)&pParty->field_777C[1] ); | 1100 while ( v7 <= &pParty->pHirelings[1] ); |
1101 } | 1101 } |
1102 } | 1102 } |
1103 // A75070: using guessed type int dword_A75070; | 1103 // A75070: using guessed type int dword_A75070; |
1104 | 1104 |
1105 //----- (00490D02) -------------------------------------------------------- | 1105 //----- (00490D02) -------------------------------------------------------- |