Skip to content

Commit

Permalink
fix signing of min/max Rank Distributions
Browse files Browse the repository at this point in the history
  • Loading branch information
sekaiwish committed Nov 7, 2023
1 parent be6f55b commit 29904d5
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 14 deletions.
23 changes: 22 additions & 1 deletion patch-schema/10-rework-distributions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,31 @@ BEGIN;
CREATE TABLE public.distribution_items
(
id serial PRIMARY KEY,
distribution_id integer,
distribution_id integer NOT NULL,
item_type integer,
item_id integer,
quantity integer
);

ALTER TABLE IF EXISTS public.distribution ALTER COLUMN min_hr DROP DEFAULT;
ALTER TABLE IF EXISTS public.distribution ALTER COLUMN max_hr DROP DEFAULT;
ALTER TABLE IF EXISTS public.distribution ALTER COLUMN min_sr DROP DEFAULT;
ALTER TABLE IF EXISTS public.distribution ALTER COLUMN max_sr DROP DEFAULT;
ALTER TABLE IF EXISTS public.distribution ALTER COLUMN min_gr DROP DEFAULT;
ALTER TABLE IF EXISTS public.distribution ALTER COLUMN max_gr DROP DEFAULT;

ALTER TABLE IF EXISTS public.distribution ALTER COLUMN min_hr DROP NOT NULL;
ALTER TABLE IF EXISTS public.distribution ALTER COLUMN max_hr DROP NOT NULL;
ALTER TABLE IF EXISTS public.distribution ALTER COLUMN min_sr DROP NOT NULL;
ALTER TABLE IF EXISTS public.distribution ALTER COLUMN max_sr DROP NOT NULL;
ALTER TABLE IF EXISTS public.distribution ALTER COLUMN min_gr DROP NOT NULL;
ALTER TABLE IF EXISTS public.distribution ALTER COLUMN max_gr DROP NOT NULL;

UPDATE distribution SET min_hr=NULL WHERE min_hr=65535;
UPDATE distribution SET max_hr=NULL WHERE max_hr=65535;
UPDATE distribution SET min_sr=NULL WHERE min_sr=65535;
UPDATE distribution SET max_sr=NULL WHERE max_sr=65535;
UPDATE distribution SET min_gr=NULL WHERE min_gr=65535;
UPDATE distribution SET max_gr=NULL WHERE max_gr=65535;

END;
28 changes: 15 additions & 13 deletions server/channelserver/handlers_distitem.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ type ItemDist struct {
Deadline time.Time `db:"deadline"`
TimesAcceptable uint16 `db:"times_acceptable"`
TimesAccepted uint16 `db:"times_accepted"`
MinHR uint16 `db:"min_hr"`
MaxHR uint16 `db:"max_hr"`
MinSR uint16 `db:"min_sr"`
MaxSR uint16 `db:"max_sr"`
MinGR uint16 `db:"min_gr"`
MaxGR uint16 `db:"max_gr"`
MinHR int16 `db:"min_hr"`
MaxHR int16 `db:"max_hr"`
MinSR int16 `db:"min_sr"`
MaxSR int16 `db:"max_sr"`
MinGR int16 `db:"min_gr"`
MaxGR int16 `db:"max_gr"`
EventName string `db:"event_name"`
Description string `db:"description"`
Data []byte `db:"data"`
Expand All @@ -31,7 +31,9 @@ func handleMsgMhfEnumerateDistItem(s *Session, p mhfpacket.MHFPacket) {
distCount := 0
dists, err := s.server.db.Queryx(`
SELECT d.id, event_name, description, times_acceptable,
min_hr, max_hr, min_sr, max_sr, min_gr, max_gr,
COALESCE(min_hr, -1) AS min_hr, COALESCE(max_hr, -1) AS max_hr,
COALESCE(min_sr, -1) AS min_sr, COALESCE(max_sr, -1) AS max_sr,
COALESCE(min_gr, -1) AS min_gr, COALESCE(max_gr, -1) AS max_gr,
(
SELECT count(*)
FROM distributions_accepted da
Expand Down Expand Up @@ -59,12 +61,12 @@ func handleMsgMhfEnumerateDistItem(s *Session, p mhfpacket.MHFPacket) {
bf.WriteUint16(distData.TimesAcceptable)
bf.WriteUint16(distData.TimesAccepted)
bf.WriteUint16(0) // Unk
bf.WriteUint16(distData.MinHR)
bf.WriteUint16(distData.MaxHR)
bf.WriteUint16(distData.MinSR)
bf.WriteUint16(distData.MaxSR)
bf.WriteUint16(distData.MinGR)
bf.WriteUint16(distData.MaxGR)
bf.WriteInt16(distData.MinHR)
bf.WriteInt16(distData.MaxHR)
bf.WriteInt16(distData.MinSR)
bf.WriteInt16(distData.MaxSR)
bf.WriteInt16(distData.MinGR)
bf.WriteInt16(distData.MaxGR)
bf.WriteUint8(0)
bf.WriteUint16(0)
bf.WriteUint8(0)
Expand Down

0 comments on commit 29904d5

Please sign in to comment.