forked from diasurgical/devilution
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpack.cpp
More file actions
302 lines (266 loc) · 8.4 KB
/
pack.cpp
File metadata and controls
302 lines (266 loc) · 8.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
#include "../types.h"
int pack_cpp_init_value; // weak
int pack_inf = 0x7F800000; // weak
//----- (0044875A) --------------------------------------------------------
struct pack_cpp_init
{
pack_cpp_init()
{
pack_cpp_init_value = pack_inf;
}
} _pack_cpp_init;
// 47F168: using guessed type int pack_inf;
// 67D7C8: using guessed type int pack_cpp_init_value;
//----- (00448765) --------------------------------------------------------
void __fastcall PackPlayer(PkPlayerStruct *pPack, int pnum, bool manashield)
{
PlayerStruct *pPlayer; // edi
int i; // [esp+8h] [ebp-Ch]
ItemStruct *pi; // [esp+Ch] [ebp-8h]
PkItemStruct *pki; // [esp+10h] [ebp-4h]
memset(pPack, 0, 0x4F2);
pPlayer = &plr[pnum];
pPack->destAction = pPlayer->destAction;
pPack->destParam1 = pPlayer->destParam1;
pPack->destParam2 = pPlayer->destParam2;
pPack->plrlevel = pPlayer->plrlevel;
pPack->px = pPlayer->WorldX;
pPack->py = pPlayer->WorldY;
pPack->targx = pPlayer->_ptargx;
pPack->targy = pPlayer->_ptargy;
strcpy(pPack->pName, pPlayer->_pName);
pPack->pClass = pPlayer->_pClass;
pPack->pBaseStr = pPlayer->_pBaseStr;
pPack->pBaseMag = pPlayer->_pBaseMag;
pPack->pBaseDex = pPlayer->_pBaseDex;
pPack->pBaseVit = pPlayer->_pBaseVit;
pPack->pLevel = pPlayer->_pLevel;
pPack->pStatPts = pPlayer->_pStatPts;
pPack->pExperience = pPlayer->_pExperience;
pPack->pGold = pPlayer->_pGold;
pPack->pHPBase = pPlayer->_pHPBase;
pPack->pMaxHPBase = pPlayer->_pMaxHPBase;
pPack->pManaBase = pPlayer->_pManaBase;
pPack->pMaxManaBase = pPlayer->_pMaxManaBase;
pPack->pMemSpells = pPlayer->_pMemSpells[0];
pPack->pMemSpells2 = pPlayer->_pMemSpells[1];
for(i = 0; i < 37; i++)
pPack->pSplLvl[i] = pPlayer->_pSplLvl[i];
pki = pPack->InvBody;
pi = pPlayer->InvBody;
for(i = 0; i < 7; i++)
PackItem(pki++, pi++);
pki = pPack->InvList;
pi = pPlayer->InvList;
for(i = 0; i < 40; i++)
PackItem(pki++, pi++);
for(i = 0; i < 40; i++)
pPack->InvGrid[i] = pPlayer->InvGrid[i];
pPack->_pNumInv = pPlayer->_pNumInv;
pki = pPack->SpdList;
pi = pPlayer->SpdList;
for(i = 0; i < 8; i++)
PackItem(pki++, pi++);
pPack->pDiabloKillLevel = pPlayer->pDiabloKillLevel;
if ( gbMaxPlayers == 1 || manashield )
pPack->pManaShield = pPlayer->pManaShield;
else
pPack->pManaShield = 0;
}
// 679660: using guessed type char gbMaxPlayers;
//----- (00448953) --------------------------------------------------------
void __fastcall PackItem(PkItemStruct *id, ItemStruct *is)
{
short v2; // ax
short v3; // bx
if ( is->_itype == -1 )
{
id->idx = -1;
}
else
{
id->idx = is->IDidx;
if ( is->IDidx == IDI_EAR )
{
_LOBYTE(v2) = 0;
_LOBYTE(v3) = 0;
_HIBYTE(v2) = is->_iName[7];
id->iCreateInfo = is->_iName[8] | v2;
id->iSeed = is->_iName[12] | ((is->_iName[11] | ((is->_iName[10] | (is->_iName[9] << 8)) << 8)) << 8);
id->bId = is->_iName[13];
id->bDur = is->_iName[14];
id->bMDur = is->_iName[15];
id->bCh = is->_iName[16];
id->bMCh = is->_iName[17];
_HIBYTE(v3) = is->_iName[18];
id->wValue = _LOWORD(is->_ivalue) | v3 | ((_LOWORD(is->_iCurs) - 19) << 6);
id->dwBuff = is->_iName[22] | ((is->_iName[21] | ((is->_iName[20] | (is->_iName[19] << 8)) << 8)) << 8);
}
else
{
id->iSeed = is->_iSeed;
id->iCreateInfo = is->_iCreateInfo;
id->bId = _LOBYTE(is->_iIdentified) + 2 * is->_iMagical;
id->bDur = is->_iDurability;
id->bMDur = is->_iMaxDur;
id->bCh = is->_iCharges;
id->bMCh = is->_iMaxCharges;
if ( !is->IDidx )
id->wValue = is->_ivalue;
}
}
}
//----- (00448A5E) --------------------------------------------------------
void __fastcall VerifyGoldSeeds(PlayerStruct *pPlayer)
{
int i; // ebp
int j; // ecx
for(i = 0; i < pPlayer->_pNumInv; i++)
{
if ( pPlayer->InvList[i].IDidx == IDI_GOLD && pPlayer->_pNumInv > 0 )
{
for(j = 0; j < pPlayer->_pNumInv; j++)
{
if ( i != j )
{
if ( pPlayer->InvList[j].IDidx == IDI_GOLD && pPlayer->InvList[i]._iSeed == pPlayer->InvList[j]._iSeed )
{
pPlayer->InvList[i]._iSeed = GetRndSeed();
j = -1;
}
}
}
}
}
}
//----- (00448AD0) --------------------------------------------------------
void __fastcall UnPackPlayer(PkPlayerStruct *pPack, int pnum, bool killok)
{
PlayerStruct *pPlayer; // esi
signed int v6; // eax
int i; // [esp+10h] [ebp-8h]
ItemStruct *pi; // [esp+14h] [ebp-4h]
PkItemStruct *pki; // [esp+20h] [ebp+8h]
pPlayer = &plr[pnum];
ClearPlrRVars(&plr[pnum]);
pPlayer->WorldX = (unsigned char)pPack->px;
pPlayer->WorldY = (unsigned char)pPack->py;
pPlayer->_px = (unsigned char)pPack->px;
pPlayer->_py = (unsigned char)pPack->py;
pPlayer->_ptargx = (unsigned char)pPack->targx;
pPlayer->_ptargy = (unsigned char)pPack->targy;
pPlayer->plrlevel = (unsigned char)pPack->plrlevel;
ClrPlrPath(pnum);
pPlayer->destAction = -1;
strcpy(pPlayer->_pName, pPack->pName);
_LOBYTE(pPlayer->_pClass) = pPack->pClass;
InitPlayer(pnum, 1);
pPlayer->_pBaseStr = (unsigned char)pPack->pBaseStr;
pPlayer->_pStrength = (unsigned char)pPack->pBaseStr;
pPlayer->_pBaseMag = (unsigned char)pPack->pBaseMag;
pPlayer->_pMagic = (unsigned char)pPack->pBaseMag;
pPlayer->_pBaseDex = (unsigned char)pPack->pBaseDex;
pPlayer->_pDexterity = (unsigned char)pPack->pBaseDex;
pPlayer->_pBaseVit = (unsigned char)pPack->pBaseVit;
pPlayer->_pVitality = (unsigned char)pPack->pBaseVit;
pPlayer->_pLevel = pPack->pLevel;
pPlayer->_pStatPts = (unsigned char)pPack->pStatPts;
pPlayer->_pExperience = pPack->pExperience;
pPlayer->_pGold = pPack->pGold;
pPlayer->_pMaxHPBase = pPack->pMaxHPBase;
v6 = pPack->pHPBase;
pPlayer->_pHPBase = v6;
if ( !killok )
{
_LOBYTE(v6) = v6 & 0xC0;
if ( v6 < 64 )
pPlayer->_pHPBase = 64;
}
pPlayer->_pMaxManaBase = pPack->pMaxManaBase;
pPlayer->_pManaBase = pPack->pManaBase;
pPlayer->_pMemSpells[0] = pPack->pMemSpells;
pPlayer->_pMemSpells[1] = pPack->pMemSpells2;
for(i = 0; i < 37; i++)
pPlayer->_pSplLvl[i] = pPack->pSplLvl[i];
pki = pPack->InvBody;
pi = pPlayer->InvBody;
for(i = 0; i < 7; i++)
UnPackItem(pki++, pi++);
pki = pPack->InvList;
pi = pPlayer->InvList;
for(i = 0; i < 40; i++)
UnPackItem(pki++, pi++);
for(i = 0; i < 40; i++)
pPlayer->InvGrid[i] = pPack->InvGrid[i];
pPlayer->_pNumInv = (unsigned char)pPack->_pNumInv;
VerifyGoldSeeds(pPlayer);
pki = pPack->SpdList;
pi = pPlayer->SpdList;
for(i = 0; i < 8; i++)
UnPackItem(pki++, pi++);
if ( pnum == myplr )
{
for(i = 0; i < 20; i++)
witchitem[i]._itype = -1;
}
CalcPlrInv(pnum, 0);
pPlayer->pTownWarps = 0;
pPlayer->pDungMsgs = 0;
pPlayer->pLvlLoad = 0;
pPlayer->pDiabloKillLevel = pPack->pDiabloKillLevel;
pPlayer->pBattleNet = pPack->pBattleNet;
pPlayer->pManaShield = pPack->pManaShield;
}
//----- (00448D48) --------------------------------------------------------
void __fastcall UnPackItem(PkItemStruct *is, ItemStruct *id)
{
PkItemStruct *v2; // esi
ItemStruct *v3; // edi
int v5; // ecx
v2 = is;
v3 = id;
if ( is->idx == -1 )
{
id->_itype = -1;
}
else
{
if ( is->idx == IDI_EAR )
{
RecreateEar(
127,
is->iCreateInfo,
is->iSeed,
is->bId,
(unsigned char)is->bDur,
(unsigned char)is->bMDur,
(unsigned char)is->bCh,
(unsigned char)is->bMCh,
(unsigned short)is->wValue,
is->dwBuff);
}
else
{
v5 = (unsigned short)is->wValue;
_LOWORD(v5) = v2->iCreateInfo;
RecreateItem(127, is->idx, v5, v2->iSeed, (unsigned short)v2->wValue);
item[127]._iMagical = (unsigned char)v2->bId >> 1;
item[127]._iIdentified = v2->bId & 1;
item[127]._iDurability = (unsigned char)v2->bDur;
item[127]._iMaxDur = (unsigned char)v2->bMDur;
item[127]._iCharges = (unsigned char)v2->bCh;
item[127]._iMaxCharges = (unsigned char)v2->bMCh;
}
qmemcpy(v3, &item[127], sizeof(ItemStruct));
}
}