| 1133 | } |
| 1134 | |
| 1135 | void SavePlayer(SaveHelper &file, const Player &player) |
| 1136 | { |
| 1137 | file.WriteLE<int32_t>(player._pmode); |
| 1138 | for (int8_t step : player.walkpath) |
| 1139 | file.WriteLE<int8_t>(step); |
| 1140 | file.WriteLE<uint8_t>(player.plractive ? 1 : 0); |
| 1141 | file.Skip(2); // Alignment |
| 1142 | file.WriteLE<int32_t>(player.destAction); |
| 1143 | file.WriteLE<int32_t>(player.destParam1); |
| 1144 | file.WriteLE<int32_t>(player.destParam2); |
| 1145 | file.WriteLE<int32_t>(static_cast<int32_t>(player.destParam3)); |
| 1146 | file.WriteLE<int32_t>(player.destParam4); |
| 1147 | file.WriteLE<uint32_t>(player.plrlevel); |
| 1148 | file.WriteLE<int32_t>(player.position.tile.x); |
| 1149 | file.WriteLE<int32_t>(player.position.tile.y); |
| 1150 | file.WriteLE<int32_t>(player.position.future.x); |
| 1151 | file.WriteLE<int32_t>(player.position.future.y); |
| 1152 | |
| 1153 | // For backwards compatibility |
| 1154 | const Point target = player.GetTargetPosition(); |
| 1155 | file.WriteLE<int32_t>(target.x); |
| 1156 | file.WriteLE<int32_t>(target.y); |
| 1157 | |
| 1158 | file.WriteLE<int32_t>(player.position.last.x); |
| 1159 | file.WriteLE<int32_t>(player.position.last.y); |
| 1160 | file.WriteLE<int32_t>(player.position.old.x); |
| 1161 | file.WriteLE<int32_t>(player.position.old.y); |
| 1162 | DisplacementOf<int16_t> offset = {}; |
| 1163 | DisplacementOf<int16_t> offset2 = {}; |
| 1164 | DisplacementOf<int16_t> velocity = {}; |
| 1165 | if (player.isWalking()) { |
| 1166 | offset = player.position.CalculateWalkingOffset(player._pdir, player.AnimInfo); |
| 1167 | offset2 = player.position.CalculateWalkingOffsetShifted8(player._pdir, player.AnimInfo); |
| 1168 | velocity = player.position.GetWalkingVelocityShifted8(player._pdir, player.AnimInfo); |
| 1169 | } |
| 1170 | file.WriteLE<int32_t>(offset.deltaX); |
| 1171 | file.WriteLE<int32_t>(offset.deltaY); |
| 1172 | file.WriteLE<int32_t>(velocity.deltaX); |
| 1173 | file.WriteLE<int32_t>(velocity.deltaY); |
| 1174 | file.WriteLE<int32_t>(static_cast<int32_t>(player._pdir)); |
| 1175 | file.Skip(4); // Unused |
| 1176 | file.WriteLE<uint32_t>(player._pgfxnum); |
| 1177 | file.Skip(4); // Skip pointer _pAnimData |
| 1178 | file.WriteLE<int32_t>(std::max(0, player.AnimInfo.ticksPerFrame - 1)); |
| 1179 | file.WriteLE<int32_t>(player.AnimInfo.tickCounterOfCurrentFrame); |
| 1180 | file.WriteLE<int32_t>(player.AnimInfo.numberOfFrames); |
| 1181 | file.WriteLE<int32_t>(player.AnimInfo.currentFrame + 1); |
| 1182 | // write _pAnimWidth for vanilla compatibility |
| 1183 | const int animWidth = player.getSpriteWidth(); |
| 1184 | file.WriteLE<int32_t>(animWidth); |
| 1185 | // write _pAnimWidth2 for vanilla compatibility |
| 1186 | file.WriteLE<int32_t>(CalculateWidth2(animWidth)); |
| 1187 | file.Skip<uint32_t>(); // Skip _peflag |
| 1188 | file.WriteLE<int32_t>(player.lightId); |
| 1189 | file.WriteLE<int32_t>(1); // _pvid |
| 1190 | |
| 1191 | file.WriteLE<int32_t>(static_cast<int8_t>(player.queuedSpell.spellId)); |
| 1192 | file.WriteLE<int8_t>(static_cast<int8_t>(player.queuedSpell.spellType)); |
no test coverage detected