mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-22 07:32:32 +01:00
feat(achievement): add rank-up notifications (#165)
RE'd putDisplayed_achievement from ZZ client DLL via Ghidra: the packet sends opcode + 1 zero byte with no achievement ID, acting as a blanket "I saw everything" signal. Server changes: - Track per-character last-displayed levels in new displayed_levels column (migration 0008) - GetAchievement compares current vs displayed levels per entry - DisplayedAchievement snapshots current levels to clear notifications - Repo, service, mock, and 3 new service tests Protbot changes: - New --action achievement: fetches achievements, shows rank-up markers, sends DISPLAYED_ACHIEVEMENT, re-fetches to verify notifications clear - Packet builders for GET/ADD/DISPLAYED_ACHIEVEMENT
This commit is contained in:
@@ -15,6 +15,7 @@ import (
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"erupe-ce/cmd/protbot/scenario"
|
||||
)
|
||||
@@ -23,7 +24,7 @@ func main() {
|
||||
signAddr := flag.String("sign-addr", "127.0.0.1:53312", "Sign server address (host:port)")
|
||||
user := flag.String("user", "", "Username")
|
||||
pass := flag.String("pass", "", "Password")
|
||||
action := flag.String("action", "login", "Action to perform: login, lobby, session, chat, quests")
|
||||
action := flag.String("action", "login", "Action to perform: login, lobby, session, chat, quests, achievement")
|
||||
message := flag.String("message", "", "Chat message to send (used with --action chat)")
|
||||
flag.Parse()
|
||||
|
||||
@@ -139,8 +140,78 @@ func main() {
|
||||
fmt.Printf("[quests] Received %d bytes of quest data\n", len(data))
|
||||
_ = scenario.Logout(result.Channel)
|
||||
|
||||
case "achievement":
|
||||
result, err := scenario.Login(*signAddr, *user, *pass)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "login failed: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
charID := result.Sign.CharIDs[0]
|
||||
if _, err := scenario.SetupSession(result.Channel, charID); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "session setup failed: %v\n", err)
|
||||
_ = result.Channel.Close()
|
||||
os.Exit(1)
|
||||
}
|
||||
if err := scenario.EnterLobby(result.Channel); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "enter lobby failed: %v\n", err)
|
||||
_ = result.Channel.Close()
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Step 1: Get current achievements.
|
||||
achs, err := scenario.GetAchievements(result.Channel, charID)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "get achievements failed: %v\n", err)
|
||||
_ = scenario.Logout(result.Channel)
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Printf("[achievement] Total points: %d\n", achs.Points)
|
||||
hasNotify := false
|
||||
for _, e := range achs.Entries {
|
||||
marker := ""
|
||||
if e.Notify {
|
||||
marker = " ** RANK UP **"
|
||||
hasNotify = true
|
||||
}
|
||||
if e.Level > 0 || e.Notify {
|
||||
fmt.Printf(" [%2d] Level %d Progress %d/%d Trophy 0x%02X%s\n",
|
||||
e.ID, e.Level, e.Progress, e.Required, e.Trophy, marker)
|
||||
}
|
||||
}
|
||||
|
||||
// Step 2: Mark as displayed if there were notifications.
|
||||
if hasNotify {
|
||||
fmt.Println("[achievement] Sending DISPLAYED_ACHIEVEMENT to acknowledge rank-ups...")
|
||||
if err := scenario.DisplayedAchievement(result.Channel); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "displayed achievement failed: %v\n", err)
|
||||
}
|
||||
// Brief pause for fire-and-forget packet to be processed.
|
||||
<-time.After(500 * time.Millisecond)
|
||||
|
||||
// Step 3: Re-fetch to verify notifications are cleared.
|
||||
achs2, err := scenario.GetAchievements(result.Channel, charID)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "re-fetch achievements failed: %v\n", err)
|
||||
} else {
|
||||
cleared := true
|
||||
for _, e := range achs2.Entries {
|
||||
if e.Notify {
|
||||
fmt.Printf(" [%2d] STILL notifying (level %d) — not cleared!\n", e.ID, e.Level)
|
||||
cleared = false
|
||||
}
|
||||
}
|
||||
if cleared {
|
||||
fmt.Println("[achievement] All rank-up notifications cleared successfully.")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fmt.Println("[achievement] No pending rank-up notifications.")
|
||||
}
|
||||
|
||||
_ = scenario.Logout(result.Channel)
|
||||
|
||||
default:
|
||||
fmt.Fprintf(os.Stderr, "unknown action: %s (supported: login, lobby, session, chat, quests)\n", *action)
|
||||
fmt.Fprintf(os.Stderr, "unknown action: %s (supported: login, lobby, session, chat, quests, achievement)\n", *action)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user