-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsorting.cpp
More file actions
executable file
·67 lines (57 loc) · 1.43 KB
/
Copy pathsorting.cpp
File metadata and controls
executable file
·67 lines (57 loc) · 1.43 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
#include "agencyinclude.h"
#include "guns.h"
int SortCompareWeaponArmory(PPOTYPE WOne, PPOTYPE WTwo)
{
if(!WOne ||!WTwo){
return 0;
}
if(WOne->weapon.filingtype != WTwo->weapon.filingtype)
{
return WTwo->weapon.filingtype - WOne->weapon.filingtype;
}
else if(WOne->weapon.classtype != WTwo->weapon.classtype)
{
return WTwo->weapon.classtype - WOne->weapon.classtype;
}
else return (strcmp(WTwo->weapon.longname, WOne->weapon.longname));
}
void SwapWeaponIndex(PPOTYPE WOne, PPOTYPE WTwo)
{
int temp;
if(WOne && WTwo){
temp = WTwo->weapon.index;
WTwo->weapon.index = WOne->weapon.index;
WOne->weapon.index = temp;
}
}
void SwapWeaponID(PPOTYPE WOne, PPOTYPE WTwo)
{
int temp;
if(WOne && WTwo){
temp = WTwo->weapon.id;
WTwo->weapon.id = WOne->weapon.id;
WOne->weapon.id = temp;
}
}
void SortArmoryWeapons(PLIST armorylist)
{
sortList(armorylist, SortCompareWeaponArmory, NULL, CompareWeaponID);
ReorderWeaponArmoryIDs(armorylist);
}
void SortPersonalWeapons(PLIST weaponlist)
{
sortList(weaponlist, SortCompareWeaponArmory, SwapWeaponIndex, CompareWeaponIndex);
}
void ReorderWeaponArmoryIDs(PLIST armorylist)
{
int counter = 1;
if(!armorylist){
return;
}
PLIST walker = armorylist;
for(walker->current = walker->head; walker->current != NULL; walker->current = walker->current->nextnode)
{
walker->current->object.weapon.id = counter;
counter++;
}
}