-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathitem-procedures.cpp
More file actions
65 lines (54 loc) · 1.67 KB
/
item-procedures.cpp
File metadata and controls
65 lines (54 loc) · 1.67 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
#include <windows.h>
#include <stdio.h>
#include "text.h"
#include "operation.h"
#include "console.h"
#include "netconfig.h"
#include "quest.h"
#include "encryption.h"
#include "license.h"
#include "version.h"
#include "battleparamentry.h"
#include "itemraretable.h"
#include "player.h"
#include "map.h"
#include "client.h"
#include "listenthread.h"
#include "lobby.h"
#include "server.h"
#include "command-functions.h"
// Gives a player's items their initial IDs when joining a game.
int ProcedureInitializeClientItems(LOBBY* l,CLIENT* c)
{
long x;
for (x = 0; x < c->playerInfo.inventory.numItems; x++) c->playerInfo.inventory.items[x].data.itemID = GetNextItemID(l,c->clientID);
return 0;
}
// Reorders a client's inventory according to the given list of 30 item IDs.
int ProcedureSortClientItems(CLIENT* c,DWORD* itemIDs)
{
PLAYER_INVENTORY sorted;
memset(&sorted,0,sizeof(PLAYER_INVENTORY));
long x,y;
operation_lock(c);
for (x = 0; x < 30; x++)
{
if (itemIDs[x] == 0xFFFFFFFF) sorted.items[x].data.itemID = 0xFFFFFFFF;
else {
y = FindItem(&c->playerInfo.inventory,itemIDs[x]);
if (y == (-1))
{
operation_unlock(c);
return 854934;
}
memcpy(&sorted.items[x],&c->playerInfo.inventory.items[y],sizeof(PLAYER_ITEM));
}
}
sorted.numItems = c->playerInfo.inventory.numItems;
sorted.hpMat = c->playerInfo.inventory.hpMat;
sorted.tpMat = c->playerInfo.inventory.tpMat;
sorted.language = c->playerInfo.inventory.language;
memcpy(&c->playerInfo.inventory,&sorted,sizeof(PLAYER_INVENTORY));
operation_unlock(c);
return 0;
}