-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·673 lines (590 loc) · 27.5 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·673 lines (590 loc) · 27.5 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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
#!/bin/bash
#
# install.sh
# Automated server-side installation script for the SpellDraft module.
# Automatically detects server environment, deploys Lua/DBC files, and triggers C++ rebuild.
#
# Resolve script directory to use as default module directory
MODULE_DIR="$(cd "$(dirname "$0")" && pwd)"
SERVER_DIR="$(cd "$MODULE_DIR/../.." && pwd)"
# Verify server root directory has AzerothCore files
if [ ! -f "$SERVER_DIR/docker-compose.yml" ] && [ ! -d "$SERVER_DIR/apps/docker" ]; then
echo "Error: Could not locate AzerothCore server root directory relative to this module."
echo "Make sure mod-spelldraft is cloned inside the server's 'modules/' folder."
exit 1
fi
echo "============================================="
echo " SpellDraft Module - Server Installation"
echo "============================================="
# ── 1. STAGE LUA SCRIPTS ──────────────────────────────────────
LUA_TARGET_DIR="$SERVER_DIR/env/dist/etc/modules/lua_scripts"
mkdir -p "$LUA_TARGET_DIR"
echo "Staging Lua scripts to: $LUA_TARGET_DIR"
# Copy config file to the root of target lua_scripts_dir
cp "$MODULE_DIR/lua/spelldraft_config.lua" "$LUA_TARGET_DIR/"
# Ensure the SpellDraft subdirectory exists in target lua_scripts_dir
mkdir -p "$LUA_TARGET_DIR/SpellDraft"
# Copy all Eluna scripts to the subdirectory
cp -r "$MODULE_DIR/lua/SpellDraft/"* "$LUA_TARGET_DIR/SpellDraft/"
echo "Lua scripts successfully staged."
# ── 2. STAGE CONFIGURATION FILE ──────────────────────────────────
CONF_TARGET_DIR="$SERVER_DIR/env/dist/etc/modules"
if [ -d "$CONF_TARGET_DIR" ]; then
if [ ! -f "$CONF_TARGET_DIR/mod_spelldraft.conf" ]; then
cp "$MODULE_DIR/conf/mod_spelldraft.conf.dist" "$CONF_TARGET_DIR/mod_spelldraft.conf"
echo "Created default configuration file: $CONF_TARGET_DIR/mod_spelldraft.conf"
else
echo "Configuration file mod_spelldraft.conf already exists, skipping overwrite."
fi
fi
# ── 3. DETECT DBC DIRECTORY & DEPLOY DBC FILES ─────────────────────
DBC_DIR=""
DBC_DEPLOYED=0
CTR_TOOL=""
# Determine if running under Docker/Podman
if command -v podman >/dev/null 2>&1 || command -v docker >/dev/null 2>&1; then
# Set rootless Podman DOCKER_HOST if socket exists
if [ -z "$DOCKER_HOST" ] && [ -S "/run/user/$(id -u)/podman/podman.sock" ]; then
export DOCKER_HOST="unix:///run/user/$(id -u)/podman/podman.sock"
fi
# Find the container management tool
CTR_TOOL="docker"
if command -v podman >/dev/null 2>&1; then
CTR_TOOL="podman"
fi
# Preferred: copy straight into the worldserver container. This works on
# every platform — on Windows/macOS the volume mountpoint lives inside the
# Docker Desktop VM and is NOT visible from the host filesystem.
WS_CONTAINER=$($CTR_TOOL ps -a --format '{{.Names}}' 2>/dev/null | grep -m1 'worldserver')
if [ -n "$WS_CONTAINER" ]; then
$CTR_TOOL exec "$WS_CONTAINER" mkdir -p /azerothcore/env/dist/data/dbc/ 2>/dev/null
if $CTR_TOOL cp "$MODULE_DIR/dbc/." "$WS_CONTAINER:/azerothcore/env/dist/data/dbc/" 2>/dev/null; then
echo "DBC files copied into container '$WS_CONTAINER' (/azerothcore/env/dist/data/dbc)."
DBC_DEPLOYED=1
else
# If the worldserver mount is read-only, try copying to client-data container (which mounts it rw)
DATA_CONTAINER=$($CTR_TOOL ps -a --format '{{.Names}}' 2>/dev/null | grep -m1 'client-data')
if [ -n "$DATA_CONTAINER" ]; then
$CTR_TOOL exec "$DATA_CONTAINER" mkdir -p /azerothcore/env/dist/data/dbc/ 2>/dev/null
if $CTR_TOOL cp "$MODULE_DIR/dbc/." "$DATA_CONTAINER:/azerothcore/env/dist/data/dbc/" 2>/dev/null; then
echo "DBC files copied into container '$DATA_CONTAINER' (/azerothcore/env/dist/data/dbc)."
DBC_DEPLOYED=1
fi
fi
fi
fi
# Fallback: copy using a temporary container mounting the volume if direct cp fails
if [ "$DBC_DEPLOYED" -ne 1 ]; then
VOL_NAME=""
for v in $($CTR_TOOL volume ls -q 2>/dev/null); do
if [[ "$v" == *"ac-client-data"* ]] || [[ "$v" == *"client-data"* ]]; then
VOL_NAME="$v"
break
fi
done
if [ -n "$VOL_NAME" ]; then
IMAGE_NAME=$($CTR_TOOL images --format '{{.Repository}}:{{.Tag}}' 2>/dev/null | grep -E 'client-data|worldserver|authserver|alpine|busybox' | head -n 1)
if [ -n "$IMAGE_NAME" ]; then
if $CTR_TOOL run --rm -v "$VOL_NAME:/data" -v "$MODULE_DIR/dbc:/src" --entrypoint "" "$IMAGE_NAME" sh -c "mkdir -p /data/dbc && cp -r /src/. /data/dbc/" 2>/dev/null; then
echo "DBC files copied into volume '$VOL_NAME' via temporary container ($IMAGE_NAME)."
DBC_DEPLOYED=1
fi
fi
fi
fi
# Fallback: resolve the client-data named volume on the host (Linux).
if [ "$DBC_DEPLOYED" -ne 1 ]; then
VOL_NAME=""
for v in $($CTR_TOOL volume ls -q 2>/dev/null); do
if [[ "$v" == *"ac-client-data"* ]]; then
VOL_NAME="$v"
break
fi
done
if [ -n "$VOL_NAME" ]; then
MOUNT_POINT=$($CTR_TOOL volume inspect "$VOL_NAME" --format '{{.Mountpoint}}' 2>/dev/null)
if [ -d "$MOUNT_POINT" ]; then
DBC_DIR="$MOUNT_POINT/dbc"
fi
fi
fi
fi
# Fallback to local compile path if container volume not found
if [ "$DBC_DEPLOYED" -ne 1 ] && [ -z "$DBC_DIR" ]; then
DBC_DIR="$SERVER_DIR/env/dist/data/dbc"
fi
# Deploy DBCs if directory found
if [ "$DBC_DEPLOYED" -eq 1 ]; then
: # already copied into the container above
elif [ -d "$DBC_DIR" ]; then
echo "Deploying custom DBC files to: $DBC_DIR"
if cp "$MODULE_DIR/dbc/"*.dbc "$DBC_DIR/"; then
echo "DBC files successfully copied."
else
echo "Error: Failed to copy DBC files to $DBC_DIR."
echo "You may need elevated permissions. Otherwise, copy the contents of dbc/ manually into your server's DBC directory (see below)."
DBC_DIR=""
fi
else
echo "Warning: Could not automatically locate your server's DBC directory."
echo "Copy the contents of dbc/ manually:"
if [ -n "$CTR_TOOL" ]; then
echo " * Docker/Podman (incl. Windows Docker Desktop): create/start the worldserver container first, then run:"
echo " $CTR_TOOL cp \"$MODULE_DIR/dbc/.\" ac-worldserver:/azerothcore/env/dist/data/dbc/"
echo " (the DBC folder lives inside the container's data volume — it does not exist on your host filesystem)"
fi
echo " * Local/repack builds: copy dbc/*.dbc into the 'dbc' folder under the DataDir path set in worldserver.conf"
echo " (default: <server>/env/dist/data/dbc)."
fi
# ── 4. PATCH CORE C++ FOR COMBO POINTS ──────────────────────────
UNIT_CPP="$SERVER_DIR/src/server/game/Entities/Unit/Unit.cpp"
if [ -f "$UNIT_CPP" ]; then
if ! grep -q "SpellDraftCP" "$UNIT_CPP"; then
echo "Patching Unit.cpp to support combo points for classless builds..."
python3 -c '
import sys
unit_cpp = sys.argv[1]
with open(unit_cpp, "r", encoding="utf-8") as f:
content = f.read()
target = "playerMe->SendDirectMessage(&data);"
replacement = """playerMe->SendDirectMessage(&data);
// Send custom SpellDraft addon message for custom combo point rendering
std::string prefix = "SpellDraftCP";
std::string message = std::to_string(m_comboPoints);
std::string fullmsg = prefix + "\\t" + message;
WorldPacket addonData(SMSG_MESSAGECHAT, 100);
addonData << uint8(0); // CHAT_MSG_ADDON (Whisper/Normal channel context)
addonData << int32(LANG_ADDON);
addonData << playerMe->GetGUID();
addonData << uint32(0);
addonData << playerMe->GetGUID();
addonData << uint32(fullmsg.length() + 1);
addonData << fullmsg;
addonData << uint8(0);
playerMe->GetSession()->SendPacket(&addonData);"""
if target in content:
content = content.replace(target, replacement, 1)
with open(unit_cpp, "w", encoding="utf-8") as f:
f.write(content)
print("Unit.cpp successfully patched.")
else:
print("Error: Could not locate target block in Unit.cpp.")
sys.exit(1)
' "$UNIT_CPP"
if [ $? -ne 0 ]; then
echo "Error: Failed to patch Unit.cpp. Aborting installation."
exit 1
fi
else
echo "Unit.cpp is already patched for SpellDraft combo points."
fi
else
echo "Warning: Could not locate Unit.cpp at $UNIT_CPP. Skipping core patch."
fi
# ── 4.5. PATCH CORE C++ FOR PET TRAINERS ──────────────────────────
TRAINER_CPP="$SERVER_DIR/src/server/game/Entities/Creature/Trainer.cpp"
if [ -f "$TRAINER_CPP" ]; then
if ! grep -q "SpellDraft.Enable" "$TRAINER_CPP"; then
echo "Patching Trainer.cpp to support pet trainers for all classes..."
python3 -c '
import sys
trainer_cpp = sys.argv[1]
with open(trainer_cpp, "r", encoding="utf-8") as f:
content = f.read()
target_inc = "#include \"Trainer.h\""
replacement_inc = "#include \"Trainer.h\"\\n#include \"Config.h\""
target_pet = """ case Type::Class:
case Type::Pet:
// check class for class trainers
return player->getClass() == GetTrainerRequirement();"""
replacement_pet = """ case Type::Class:
// check class for class trainers
return player->getClass() == GetTrainerRequirement();
case Type::Pet:
// check class for pet trainers (allow any class if SpellDraft is enabled)
if (sConfigMgr->GetOption<bool>("SpellDraft.Enable", true))
return true;
return player->getClass() == GetTrainerRequirement();"""
if target_inc in content and target_pet in content:
content = content.replace(target_inc, replacement_inc, 1)
content = content.replace(target_pet, replacement_pet, 1)
with open(trainer_cpp, "w", encoding="utf-8") as f:
f.write(content)
print("Trainer.cpp successfully patched.")
else:
print("Error: Could not locate target blocks in Trainer.cpp.")
sys.exit(1)
' "$TRAINER_CPP"
if [ $? -ne 0 ]; then
echo "Error: Failed to patch Trainer.cpp. Aborting installation."
exit 1
fi
else
echo "Trainer.cpp is already patched for SpellDraft pet trainers."
fi
else
echo "Warning: Could not locate Trainer.cpp at $TRAINER_CPP. Skipping core patch."
fi
# ── 4.6. PATCH CORE C++ FOR PLAYER.H STABLES ──────────────────────────
PLAYER_H="$SERVER_DIR/src/server/game/Entities/Player/Player.h"
if [ -f "$PLAYER_H" ]; then
if ! grep -q "ShowCustomStableMenu" "$PLAYER_H"; then
echo "Patching Player.h to support custom stable gossip helper declarations..."
python3 -c '
import sys
player_h = sys.argv[1]
with open(player_h, "r", encoding="utf-8") as f:
content = f.read()
target = "void OnGossipSelect(WorldObject* source, uint32 gossipListId, uint32 menuId);"
replacement = """void OnGossipSelect(WorldObject* source, uint32 gossipListId, uint32 menuId);
void ShowCustomStableMenu(WorldObject* source);
void HandleCustomStableGossip(WorldObject* source, uint32 action);"""
if target in content:
content = content.replace(target, replacement, 1)
with open(player_h, "w", encoding="utf-8") as f:
f.write(content)
print("Player.h successfully patched.")
else:
print("Error: Could not locate target block in Player.h.")
sys.exit(1)
' "$PLAYER_H"
if [ $? -ne 0 ]; then
echo "Error: Failed to patch Player.h. Aborting installation."
exit 1
fi
else
echo "Player.h is already patched for custom stable gossip helper declarations."
fi
else
echo "Warning: Could not locate Player.h at $PLAYER_H. Skipping core patch."
fi
# ── 4.7. PATCH CORE C++ FOR PLAYERGOSSIP.CPP STABLES ──────────────────
PLAYERGOSSIP_CPP="$SERVER_DIR/src/server/game/Entities/Player/PlayerGossip.cpp"
if [ -f "$PLAYERGOSSIP_CPP" ]; then
if ! grep -q "ShowCustomStableMenu" "$PLAYERGOSSIP_CPP"; then
echo "Patching PlayerGossip.cpp to support custom stable gossip..."
python3 -c '
import sys
playergossip_cpp = sys.argv[1]
with open(playergossip_cpp, "r", encoding="utf-8") as f:
content = f.read()
target_inc = "#include \"WorldSession.h\""
replacement_inc = "#include \"WorldSession.h\"\\n#include \"DatabaseEnv.h\""
target_select = """ uint32 gossipOptionId = item->OptionType;
ObjectGuid guid = source->GetGUID();"""
replacement_select = """ uint32 gossipOptionId = item->OptionType;
ObjectGuid guid = source->GetGUID();
if (gossipOptionId >= 1000)
{
HandleCustomStableGossip(source, gossipOptionId);
return;
}"""
target_gossip = """ case GOSSIP_OPTION_STABLEPET:
GetSession()->SendStablePet(guid);
break;"""
replacement_gossip = """ case GOSSIP_OPTION_STABLEPET:
if (sConfigMgr->GetOption<bool>("SpellDraft.Enable", true) && getClass() != CLASS_HUNTER)
{
ShowCustomStableMenu(source);
}
else
{
GetSession()->SendStablePet(guid);
}
break;"""
target_menu = """ menu->GetGossipMenu().AddMenuItem(itr->second.OptionID, itr->second.OptionIcon, strOptionText, 0, itr->second.OptionType, strBoxText, itr->second.BoxMoney, itr->second.BoxCoded);"""
replacement_menu = """ uint32 optionType = itr->second.OptionType;
uint8 optionIcon = itr->second.OptionIcon;
if (optionType == GOSSIP_OPTION_STABLEPET && sConfigMgr->GetOption<bool>("SpellDraft.Enable", true) && getClass() != CLASS_HUNTER)
{
optionType = 1007;
optionIcon = GOSSIP_ICON_CHAT;
}
menu->GetGossipMenu().AddMenuItem(itr->second.OptionID, optionIcon, strOptionText, 0, optionType, strBoxText, itr->second.BoxMoney, itr->second.BoxCoded);"""
target_end = """void Player::ToggleInstantFlight()
{
m_isInstantFlightOn = !m_isInstantFlightOn;
}"""
replacement_end = """void Player::ToggleInstantFlight()
{
m_isInstantFlightOn = !m_isInstantFlightOn;
}
void Player::ShowCustomStableMenu(WorldObject* source)
{
PlayerTalkClass->ClearMenus();
PetStable* petStable = GetPetStable();
if (!petStable)
{
petStable = &GetOrInitPetStable();
}
Pet* pet = GetPet();
if (pet && pet->IsAlive() && pet->getPetType() == HUNTER_PET)
{
std::string label = "Stable current pet: " + pet->GetName() + " (Level " + std::to_string(pet->GetLevel()) + ")";
PlayerTalkClass->GetGossipMenu().AddMenuItem(-1, GOSSIP_ICON_CHAT, label, 0, 1001, "", 0, false);
}
else if (petStable->CurrentPet)
{
std::string label = "Call pet: " + petStable->CurrentPet->Name + " (Level " + std::to_string(uint32(petStable->CurrentPet->Level)) + ")";
PlayerTalkClass->GetGossipMenu().AddMenuItem(-1, GOSSIP_ICON_CHAT, label, 0, 1006, "", 0, false);
std::string labelStable = "Stable pet: " + petStable->CurrentPet->Name + " (Level " + std::to_string(uint32(petStable->CurrentPet->Level)) + ")";
PlayerTalkClass->GetGossipMenu().AddMenuItem(-1, GOSSIP_ICON_CHAT, labelStable, 0, 1001, "", 0, false);
}
for (uint32 i = 0; i < petStable->MaxStabledPets; ++i)
{
if (petStable->StabledPets[i])
{
std::string label = "Retrieve stabled pet " + std::to_string(i + 1) + ": " +
petStable->StabledPets[i]->Name + " (Level " +
std::to_string(uint32(petStable->StabledPets[i]->Level)) + ")";
PlayerTalkClass->GetGossipMenu().AddMenuItem(-1, GOSSIP_ICON_CHAT, label, 0, 1002 + i, "", 0, false);
}
else
{
PlayerTalkClass->GetGossipMenu().AddMenuItem(-1, GOSSIP_ICON_CHAT, "Stable slot " + std::to_string(i + 1) + " [Empty]", 0, 1000, "", 0, false);
}
}
PlayerTalkClass->GetGossipMenu().AddMenuItem(-1, GOSSIP_ICON_CHAT, "Goodbye", 0, GOSSIP_OPTION_QUESTGIVER, "", 0, false);
PlayerTalkClass->SendGossipMenu(4783, source->GetGUID());
}
void Player::HandleCustomStableGossip(WorldObject* source, uint32 action)
{
PetStable* petStable = GetPetStable();
if (!petStable)
return;
if (action == 1007) // Initial click on stable master option
{
ShowCustomStableMenu(source);
}
else if (action == 1001) // Stable pet
{
Pet* pet = GetPet();
int freeSlot = -1;
for (uint32 i = 0; i < petStable->MaxStabledPets; ++i)
{
if (!petStable->StabledPets[i])
{
freeSlot = i;
break;
}
}
if (freeSlot == -1)
{
ChatHandler(GetSession()).SendNotification("Your stable is full!");
ShowCustomStableMenu(source);
return;
}
if (pet)
{
RemovePet(pet, PetSaveMode(PET_SAVE_FIRST_STABLE_SLOT + freeSlot));
std::swap(petStable->StabledPets[freeSlot], petStable->CurrentPet);
ChatHandler(GetSession()).SendNotification("Pet stabled successfully.");
}
else if (petStable->CurrentPet)
{
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_PET_SLOT_BY_ID);
stmt->SetData(0, PetSaveMode(PET_SAVE_FIRST_STABLE_SLOT + freeSlot));
stmt->SetData(1, GetGUID().GetCounter());
stmt->SetData(2, petStable->CurrentPet->PetNumber);
CharacterDatabase.Execute(stmt);
petStable->StabledPets[freeSlot] = std::move(petStable->CurrentPet);
petStable->CurrentPet.reset();
ChatHandler(GetSession()).SendNotification("Pet stabled successfully.");
}
ShowCustomStableMenu(source);
}
else if (action >= 1002 && action <= 1005) // Retrieve pet
{
uint32 slot = action - 1002;
if (slot >= petStable->MaxStabledPets || !petStable->StabledPets[slot])
{
ShowCustomStableMenu(source);
return;
}
Pet* activePet = GetPet();
if (activePet)
{
RemovePet(activePet, PetSaveMode(PET_SAVE_FIRST_STABLE_SLOT + slot));
std::swap(petStable->StabledPets[slot], petStable->CurrentPet);
uint32 petnumber = petStable->CurrentPet->PetNumber;
Pet* newPet = new Pet(this, HUNTER_PET);
if (!newPet->LoadPetFromDB(this, 0, petnumber, false))
{
delete newPet;
ChatHandler(GetSession()).SendNotification("Failed to load pet.");
}
else
{
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_PET_SLOT_BY_ID);
stmt->SetData(0, PET_SAVE_AS_CURRENT);
stmt->SetData(1, GetGUID().GetCounter());
stmt->SetData(2, petnumber);
CharacterDatabase.Execute(stmt);
ChatHandler(GetSession()).SendNotification("Pets swapped successfully.");
}
}
else
{
petStable->CurrentPet = std::move(petStable->StabledPets[slot]);
petStable->StabledPets[slot].reset();
uint32 petnumber = petStable->CurrentPet->PetNumber;
Pet* newPet = new Pet(this, HUNTER_PET);
if (!newPet->LoadPetFromDB(this, 0, petnumber, false))
{
delete newPet;
ChatHandler(GetSession()).SendNotification("Failed to load pet.");
}
else
{
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_PET_SLOT_BY_ID);
stmt->SetData(0, PET_SAVE_AS_CURRENT);
stmt->SetData(1, GetGUID().GetCounter());
stmt->SetData(2, petnumber);
CharacterDatabase.Execute(stmt);
ChatHandler(GetSession()).SendNotification("Pet retrieved successfully.");
}
}
ShowCustomStableMenu(source);
}
else if (action == 1006) // Call pet
{
if (petStable->CurrentPet)
{
uint32 petnumber = petStable->CurrentPet->PetNumber;
Pet* newPet = new Pet(this, HUNTER_PET);
if (!newPet->LoadPetFromDB(this, 0, petnumber, false))
{
delete newPet;
ChatHandler(GetSession()).SendNotification("Failed to call pet.");
}
else
{
ChatHandler(GetSession()).SendNotification("Pet called successfully.");
}
}
ShowCustomStableMenu(source);
}
else
{
ShowCustomStableMenu(source);
}
}"""
if target_inc in content:
content = content.replace(target_inc, replacement_inc, 1)
if target_menu in content:
content = content.replace(target_menu, replacement_menu, 1)
if target_select in content:
content = content.replace(target_select, replacement_select, 1)
if target_gossip in content:
content = content.replace(target_gossip, replacement_gossip, 1)
if target_end in content:
content = content.replace(target_end, replacement_end, 1)
with open(playergossip_cpp, "w", encoding="utf-8") as f:
f.write(content)
print("PlayerGossip.cpp successfully patched.")
' "$PLAYERGOSSIP_CPP"
if [ $? -ne 0 ]; then
echo "Error: Failed to patch PlayerGossip.cpp. Aborting installation."
exit 1
fi
else
echo "PlayerGossip.cpp is already patched for custom stable gossip."
fi
else
echo "Warning: Could not locate PlayerGossip.cpp at $PLAYERGOSSIP_CPP. Skipping core patch."
fi
# ── 4.8. PATCH CORE C++ FOR PLAYERSTORAGE.CPP SHIELDS/RELICS ──────────────────
PLAYERSTORAGE_CPP="$SERVER_DIR/src/server/game/Entities/Player/PlayerStorage.cpp"
if [ -f "$PLAYERSTORAGE_CPP" ]; then
if ! grep -q "SpellDraft.Enable" "$PLAYERSTORAGE_CPP"; then
echo "Patching PlayerStorage.cpp to support shields/relics for all classes..."
python3 -c '
import sys
playerstorage_cpp = sys.argv[1]
with open(playerstorage_cpp, "r", encoding="utf-8") as f:
content = f.read()
target_shield = """ // Check for shields
if (proto->SubClass == ITEM_SUBCLASS_ARMOR_SHIELD && !(
IsClass(CLASS_PALADIN, CLASS_CONTEXT_EQUIP_SHIELDS)
|| IsClass(CLASS_WARRIOR, CLASS_CONTEXT_EQUIP_SHIELDS)
|| IsClass(CLASS_SHAMAN, CLASS_CONTEXT_EQUIP_SHIELDS)))"""
replacement_shield = """ // Check for shields
if (proto->SubClass == ITEM_SUBCLASS_ARMOR_SHIELD && !(
IsClass(CLASS_PALADIN, CLASS_CONTEXT_EQUIP_SHIELDS)
|| IsClass(CLASS_WARRIOR, CLASS_CONTEXT_EQUIP_SHIELDS)
|| IsClass(CLASS_SHAMAN, CLASS_CONTEXT_EQUIP_SHIELDS)
|| sConfigMgr->GetOption<bool>("SpellDraft.Enable", true)))"""
target_libram = """ // Check for librams.
if (proto->SubClass == ITEM_SUBCLASS_ARMOR_LIBRAM && !IsClass(CLASS_PALADIN, CLASS_CONTEXT_EQUIP_RELIC))"""
replacement_libram = """ // Check for librams.
if (proto->SubClass == ITEM_SUBCLASS_ARMOR_LIBRAM && !IsClass(CLASS_PALADIN, CLASS_CONTEXT_EQUIP_RELIC) && !sConfigMgr->GetOption<bool>("SpellDraft.Enable", true))"""
target_idol = """ // CHeck for idols.
if (proto->SubClass == ITEM_SUBCLASS_ARMOR_IDOL && !IsClass(CLASS_DRUID, CLASS_CONTEXT_EQUIP_RELIC))"""
replacement_idol = """ // CHeck for idols.
if (proto->SubClass == ITEM_SUBCLASS_ARMOR_IDOL && !IsClass(CLASS_DRUID, CLASS_CONTEXT_EQUIP_RELIC) && !sConfigMgr->GetOption<bool>("SpellDraft.Enable", true))"""
target_totem = """ // Check for totems.
if (proto->SubClass == ITEM_SUBCLASS_ARMOR_TOTEM && !IsClass(CLASS_SHAMAN, CLASS_CONTEXT_EQUIP_RELIC))"""
replacement_totem = """ // Check for totems.
if (proto->SubClass == ITEM_SUBCLASS_ARMOR_TOTEM && !IsClass(CLASS_SHAMAN, CLASS_CONTEXT_EQUIP_RELIC) && !sConfigMgr->GetOption<bool>("SpellDraft.Enable", true))"""
target_sigil = """ // Check for sigils.
if (proto->SubClass == ITEM_SUBCLASS_ARMOR_SIGIL && !IsClass(CLASS_DEATH_KNIGHT, CLASS_CONTEXT_EQUIP_RELIC))"""
replacement_sigil = """ // Check for sigils.
if (proto->SubClass == ITEM_SUBCLASS_ARMOR_SIGIL && !IsClass(CLASS_DEATH_KNIGHT, CLASS_CONTEXT_EQUIP_RELIC) && !sConfigMgr->GetOption<bool>("SpellDraft.Enable", true))"""
if target_shield in content and target_libram in content and target_idol in content and target_totem in content and target_sigil in content:
content = content.replace(target_shield, replacement_shield, 1)
content = content.replace(target_libram, replacement_libram, 1)
content = content.replace(target_idol, replacement_idol, 1)
content = content.replace(target_totem, replacement_totem, 1)
content = content.replace(target_sigil, replacement_sigil, 1)
with open(playerstorage_cpp, "w", encoding="utf-8") as f:
f.write(content)
print("PlayerStorage.cpp successfully patched.")
else:
print("Error: Could not locate target blocks in PlayerStorage.cpp.")
sys.exit(1)
' "$PLAYERSTORAGE_CPP"
if [ $? -ne 0 ]; then
echo "Error: Failed to patch PlayerStorage.cpp. Aborting installation."
exit 1
fi
else
echo "PlayerStorage.cpp is already patched for custom shields and relics."
fi
else
echo "Warning: Could not locate PlayerStorage.cpp at $PLAYERSTORAGE_CPP. Skipping core patch."
fi
# ── 5. REBUILD WORLDSERVER IMAGE ───────────────────────────────
if [ -f "$SERVER_DIR/docker-compose.yml" ]; then
echo "---------------------------------------------"
echo "Rebuilding worldserver container image to compile SpellDraft C++..."
# Detect an available compose command.
# Docker options are tried first so Docker-only hosts behave exactly as before;
# the podman fallbacks are only reached when no docker compose is available.
COMPOSE_CMD=""
if docker compose version >/dev/null 2>&1; then
COMPOSE_CMD="docker compose"
elif command -v docker-compose >/dev/null 2>&1; then
COMPOSE_CMD="docker-compose"
elif podman compose version >/dev/null 2>&1; then
COMPOSE_CMD="podman compose"
elif command -v podman-compose >/dev/null 2>&1; then
COMPOSE_CMD="podman-compose"
fi
if [ -z "$COMPOSE_CMD" ]; then
echo "No Docker/Podman compose tool detected. Please compile the C++ changes manually (e.g. using CMake)."
echo "============================================="
echo " SpellDraft Server Installation Complete!"
echo "============================================="
exit 0
fi
if (cd "$SERVER_DIR" && $COMPOSE_CMD build ac-worldserver); then
echo "---------------------------------------------"
echo "Rebuild complete. Please restart your server container to apply updates."
else
echo "Error: Docker build failed."
exit 1
fi
fi
echo "============================================="
echo " SpellDraft Server Installation Complete!"
echo "============================================="