mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-13 15:34:38 +01:00
automate netcafe reset
This commit is contained in:
13
bundled-schema/NetcafeDefaults.sql
Normal file
13
bundled-schema/NetcafeDefaults.sql
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
BEGIN;
|
||||||
|
|
||||||
|
INSERT INTO public.cafebonus (time_req, item_type, item_id, quantity)
|
||||||
|
VALUES
|
||||||
|
(1800, 17, 0, 250),
|
||||||
|
(3600, 17, 0, 500),
|
||||||
|
(7200, 17, 0, 1000),
|
||||||
|
(10800, 17, 0, 1500),
|
||||||
|
(18000, 17, 0, 1750),
|
||||||
|
(28800, 17, 0, 3000),
|
||||||
|
(43200, 17, 0, 4000);
|
||||||
|
|
||||||
|
END;
|
||||||
6
patch-schema/netcafe-2.sql
Normal file
6
patch-schema/netcafe-2.sql
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
BEGIN;
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS public.characters
|
||||||
|
ADD COLUMN cafe_reset timestamp without time zone;
|
||||||
|
|
||||||
|
END;
|
||||||
@@ -27,14 +27,4 @@ CREATE TABLE IF NOT EXISTS public.cafe_accepted
|
|||||||
character_id integer NOT NULL
|
character_id integer NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO public.cafebonus (time_req, item_type, item_id, quantity)
|
|
||||||
VALUES
|
|
||||||
(1800, 17, 0, 250),
|
|
||||||
(3600, 17, 0, 500),
|
|
||||||
(7200, 17, 0, 1000),
|
|
||||||
(10800, 17, 0, 1500),
|
|
||||||
(18000, 17, 0, 1750),
|
|
||||||
(28800, 17, 0, 3000),
|
|
||||||
(43200, 17, 0, 4000);
|
|
||||||
|
|
||||||
END;
|
END;
|
||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"erupe-ce/common/byteframe"
|
"erupe-ce/common/byteframe"
|
||||||
ps "erupe-ce/common/pascalstring"
|
ps "erupe-ce/common/pascalstring"
|
||||||
"erupe-ce/network/mhfpacket"
|
"erupe-ce/network/mhfpacket"
|
||||||
|
"fmt"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"io"
|
"io"
|
||||||
"time"
|
"time"
|
||||||
@@ -71,15 +72,22 @@ func handleMsgMhfGetCafeDuration(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
pkt := p.(*mhfpacket.MsgMhfGetCafeDuration)
|
pkt := p.(*mhfpacket.MsgMhfGetCafeDuration)
|
||||||
bf := byteframe.NewByteFrame()
|
bf := byteframe.NewByteFrame()
|
||||||
|
|
||||||
|
var cafeReset time.Time
|
||||||
|
err := s.server.db.QueryRow(`SELECT cafe_reset FROM characters WHERE id=$1`, s.charID).Scan(&cafeReset)
|
||||||
|
if Time_Current_Adjusted().After(cafeReset) {
|
||||||
|
cafeReset = TimeWeekNext()
|
||||||
|
s.server.db.Exec(`UPDATE characters SET cafe_time=0, cafe_reset=$1 WHERE id=$2`, cafeReset, s.charID)
|
||||||
|
}
|
||||||
|
|
||||||
var cafeTime uint32
|
var cafeTime uint32
|
||||||
err := s.server.db.QueryRow("SELECT cafe_time FROM characters WHERE id = $1", s.charID).Scan(&cafeTime)
|
err = s.server.db.QueryRow("SELECT cafe_time FROM characters WHERE id = $1", s.charID).Scan(&cafeTime)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
cafeTime = uint32(Time_Current_Adjusted().Unix()) - uint32(s.sessionStart) + cafeTime
|
cafeTime = uint32(Time_Current_Adjusted().Unix()) - uint32(s.sessionStart) + cafeTime
|
||||||
bf.WriteUint32(cafeTime) // Total cafe time
|
bf.WriteUint32(cafeTime) // Total cafe time
|
||||||
bf.WriteUint16(0)
|
bf.WriteUint16(0)
|
||||||
ps.Uint16(bf, "Resets at next maintenance", true)
|
ps.Uint16(bf, fmt.Sprintf("Resets after %s %d", cafeReset.Month().String(), cafeReset.Day()), true)
|
||||||
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user