diff --git a/datastore/ac-happy-home-designer/add_to_buffer_queue.go b/datastore/ac-happy-home-designer/add_to_buffer_queue.go new file mode 100644 index 00000000..0b6feda5 --- /dev/null +++ b/datastore/ac-happy-home-designer/add_to_buffer_queue.go @@ -0,0 +1,61 @@ +// Package protocol implements the Animal Crossing: Happy Home Designer protocol +package protocol + +import ( + "fmt" + + "github.com/PretendoNetwork/nex-go/v2" + "github.com/PretendoNetwork/nex-go/v2/types" + datastore_ac_happy_home_designer_types "github.com/PretendoNetwork/nex-protocols-go/v2/datastore/ac-happy-home-designer/types" + "github.com/PretendoNetwork/nex-protocols-go/v2/globals" +) + +func (protocol *Protocol) handleAddToBufferQueue(packet nex.PacketInterface) { + if protocol.AddToBufferQueue == nil { + err := nex.NewError(nex.ResultCodes.Core.NotImplemented, "DataStoreACHappyHomeDesigner::AddToBufferQueue not implemented") + + globals.Logger.Warning(err.Message) + globals.RespondError(packet, ProtocolID, err) + + return + } + + request := packet.RMCMessage() + callID := request.CallID + parameters := request.Parameters + endpoint := packet.Sender().Endpoint() + parametersStream := nex.NewByteStreamIn(parameters, endpoint.LibraryVersions(), endpoint.ByteStreamSettings()) + + param := datastore_ac_happy_home_designer_types.NewBufferQueueParam() + buffer := types.NewQBuffer(nil) + + var err error + + err = param.ExtractFrom(parametersStream) + if err != nil { + _, rmcError := protocol.AddToBufferQueue(fmt.Errorf("Failed to read param from parameters. %s", err.Error()), packet, callID, nil, nil) + if rmcError != nil { + globals.RespondError(packet, ProtocolID, rmcError) + } + + return + } + + err = buffer.ExtractFrom(parametersStream) + if err != nil { + _, rmcError := protocol.AddToBufferQueue(fmt.Errorf("Failed to read buffer from parameters. %s", err.Error()), packet, callID, nil, nil) + if rmcError != nil { + globals.RespondError(packet, ProtocolID, rmcError) + } + + return + } + + rmcMessage, rmcError := protocol.AddToBufferQueue(nil, packet, callID, param, buffer) + if rmcError != nil { + globals.RespondError(packet, ProtocolID, rmcError) + return + } + + globals.Respond(packet, rmcMessage) +} diff --git a/datastore/ac-happy-home-designer/clear_buffer_queues.go b/datastore/ac-happy-home-designer/clear_buffer_queues.go new file mode 100644 index 00000000..ed6df43d --- /dev/null +++ b/datastore/ac-happy-home-designer/clear_buffer_queues.go @@ -0,0 +1,49 @@ +// Package protocol implements the Animal Crossing: Happy Home Designer protocol +package protocol + +import ( + "fmt" + + "github.com/PretendoNetwork/nex-go/v2" + "github.com/PretendoNetwork/nex-go/v2/types" + datastore_ac_happy_home_designer_types "github.com/PretendoNetwork/nex-protocols-go/v2/datastore/ac-happy-home-designer/types" + "github.com/PretendoNetwork/nex-protocols-go/v2/globals" +) + +func (protocol *Protocol) handleClearBufferQueues(packet nex.PacketInterface) { + if protocol.AddToBufferQueue == nil { + err := nex.NewError(nex.ResultCodes.Core.NotImplemented, "DataStoreACHappyHomeDesigner::ClearBufferQueues not implemented") + + globals.Logger.Warning(err.Message) + globals.RespondError(packet, ProtocolID, err) + + return + } + + request := packet.RMCMessage() + callID := request.CallID + parameters := request.Parameters + endpoint := packet.Sender().Endpoint() + parametersStream := nex.NewByteStreamIn(parameters, endpoint.LibraryVersions(), endpoint.ByteStreamSettings()) + + params := types.NewList[*datastore_ac_happy_home_designer_types.BufferQueueParam]() + params.Type = datastore_ac_happy_home_designer_types.NewBufferQueueParam() + + err := params.ExtractFrom(parametersStream) + if err != nil { + _, rmcError := protocol.ClearBufferQueues(fmt.Errorf("Failed to read params from parameters. %s", err.Error()), packet, callID, nil) + if rmcError != nil { + globals.RespondError(packet, ProtocolID, rmcError) + } + + return + } + + rmcMessage, rmcError := protocol.ClearBufferQueues(nil, packet, callID, params) + if rmcError != nil { + globals.RespondError(packet, ProtocolID, rmcError) + return + } + + globals.Respond(packet, rmcMessage) +} diff --git a/datastore/ac-happy-home-designer/get_buffer_queue.go b/datastore/ac-happy-home-designer/get_buffer_queue.go new file mode 100644 index 00000000..c05162a2 --- /dev/null +++ b/datastore/ac-happy-home-designer/get_buffer_queue.go @@ -0,0 +1,47 @@ +// Package protocol implements the Animal Crossing: Happy Home Designer protocol +package protocol + +import ( + "fmt" + + "github.com/PretendoNetwork/nex-go/v2" + datastore_ac_happy_home_designer_types "github.com/PretendoNetwork/nex-protocols-go/v2/datastore/ac-happy-home-designer/types" + "github.com/PretendoNetwork/nex-protocols-go/v2/globals" +) + +func (protocol *Protocol) handleGetBufferQueue(packet nex.PacketInterface) { + if protocol.AddToBufferQueue == nil { + err := nex.NewError(nex.ResultCodes.Core.NotImplemented, "DataStoreACHappyHomeDesigner::GetBufferQueue not implemented") + + globals.Logger.Warning(err.Message) + globals.RespondError(packet, ProtocolID, err) + + return + } + + request := packet.RMCMessage() + callID := request.CallID + parameters := request.Parameters + endpoint := packet.Sender().Endpoint() + parametersStream := nex.NewByteStreamIn(parameters, endpoint.LibraryVersions(), endpoint.ByteStreamSettings()) + + param := datastore_ac_happy_home_designer_types.NewBufferQueueParam() + + err := param.ExtractFrom(parametersStream) + if err != nil { + _, rmcError := protocol.GetBufferQueue(fmt.Errorf("Failed to read param from parameters. %s", err.Error()), packet, callID, nil) + if rmcError != nil { + globals.RespondError(packet, ProtocolID, rmcError) + } + + return + } + + rmcMessage, rmcError := protocol.GetBufferQueue(nil, packet, callID, param) + if rmcError != nil { + globals.RespondError(packet, ProtocolID, rmcError) + return + } + + globals.Respond(packet, rmcMessage) +} diff --git a/datastore/ac-happy-home-designer/get_buffer_queues.go b/datastore/ac-happy-home-designer/get_buffer_queues.go new file mode 100644 index 00000000..4d1b70ac --- /dev/null +++ b/datastore/ac-happy-home-designer/get_buffer_queues.go @@ -0,0 +1,49 @@ +// Package protocol implements the Animal Crossing: Happy Home Designer protocol +package protocol + +import ( + "fmt" + + "github.com/PretendoNetwork/nex-go/v2" + "github.com/PretendoNetwork/nex-go/v2/types" + datastore_ac_happy_home_designer_types "github.com/PretendoNetwork/nex-protocols-go/v2/datastore/ac-happy-home-designer/types" + "github.com/PretendoNetwork/nex-protocols-go/v2/globals" +) + +func (protocol *Protocol) handleGetBufferQueues(packet nex.PacketInterface) { + if protocol.AddToBufferQueue == nil { + err := nex.NewError(nex.ResultCodes.Core.NotImplemented, "DataStoreACHappyHomeDesigner::GetBufferQueues not implemented") + + globals.Logger.Warning(err.Message) + globals.RespondError(packet, ProtocolID, err) + + return + } + + request := packet.RMCMessage() + callID := request.CallID + parameters := request.Parameters + endpoint := packet.Sender().Endpoint() + parametersStream := nex.NewByteStreamIn(parameters, endpoint.LibraryVersions(), endpoint.ByteStreamSettings()) + + params := types.NewList[*datastore_ac_happy_home_designer_types.BufferQueueParam]() + params.Type = datastore_ac_happy_home_designer_types.NewBufferQueueParam() + + err := params.ExtractFrom(parametersStream) + if err != nil { + _, rmcError := protocol.GetBufferQueues(fmt.Errorf("Failed to read params from parameters. %s", err.Error()), packet, callID, nil) + if rmcError != nil { + globals.RespondError(packet, ProtocolID, rmcError) + } + + return + } + + rmcMessage, rmcError := protocol.GetBufferQueues(nil, packet, callID, params) + if rmcError != nil { + globals.RespondError(packet, ProtocolID, rmcError) + return + } + + globals.Respond(packet, rmcMessage) +} diff --git a/datastore/ac-happy-home-designer/get_contest_entry_count.go b/datastore/ac-happy-home-designer/get_contest_entry_count.go new file mode 100644 index 00000000..66f17fd3 --- /dev/null +++ b/datastore/ac-happy-home-designer/get_contest_entry_count.go @@ -0,0 +1,47 @@ +// Package protocol implements the Animal Crossing: Happy Home Designer protocol +package protocol + +import ( + "fmt" + + "github.com/PretendoNetwork/nex-go/v2" + "github.com/PretendoNetwork/nex-go/v2/types" + "github.com/PretendoNetwork/nex-protocols-go/v2/globals" +) + +func (protocol *Protocol) handleGetContestEntryCount(packet nex.PacketInterface) { + if protocol.GetObjectInfos == nil { + err := nex.NewError(nex.ResultCodes.Core.NotImplemented, "DataStoreACHappyHomeDesigner::GetContestEntryCount not implemented") + + globals.Logger.Warning(err.Message) + globals.RespondError(packet, ProtocolID, err) + + return + } + + request := packet.RMCMessage() + callID := request.CallID + parameters := request.Parameters + endpoint := packet.Sender().Endpoint() + parametersStream := nex.NewByteStreamIn(parameters, endpoint.LibraryVersions(), endpoint.ByteStreamSettings()) + + param := types.NewPrimitiveU32(0) + + err := param.ExtractFrom(parametersStream) + if err != nil { + _, rmcError := protocol.GetContestEntryCount(fmt.Errorf("Failed to read param from parameters. %s", err.Error()), packet, callID, nil) + if rmcError != nil { + globals.RespondError(packet, ProtocolID, rmcError) + } + + return + } + + rmcMessage, rmcError := protocol.GetContestEntryCount(nil, packet, callID, param) + if rmcError != nil { + globals.RespondError(packet, ProtocolID, rmcError) + return + } + + globals.Respond(packet, rmcMessage) +} diff --git a/datastore/ac-happy-home-designer/get_meta_by_owner_id.go b/datastore/ac-happy-home-designer/get_meta_by_owner_id.go new file mode 100644 index 00000000..72fe2d36 --- /dev/null +++ b/datastore/ac-happy-home-designer/get_meta_by_owner_id.go @@ -0,0 +1,47 @@ +// Package protocol implements the Animal Crossing: Happy Home Designer protocol +package protocol + +import ( + "fmt" + + "github.com/PretendoNetwork/nex-go/v2" + datastore_ac_happy_home_designer_types "github.com/PretendoNetwork/nex-protocols-go/v2/datastore/ac-happy-home-designer/types" + "github.com/PretendoNetwork/nex-protocols-go/v2/globals" +) + +func (protocol *Protocol) handleGetMetaByOwnerID(packet nex.PacketInterface) { + if protocol.GetMetaByOwnerID == nil { + err := nex.NewError(nex.ResultCodes.Core.NotImplemented, "DataStoreACHappyHomeDesigner::GetMetaByOwnerID not implemented") + + globals.Logger.Warning(err.Message) + globals.RespondError(packet, ProtocolID, err) + + return + } + + request := packet.RMCMessage() + callID := request.CallID + parameters := request.Parameters + endpoint := packet.Sender().Endpoint() + parametersStream := nex.NewByteStreamIn(parameters, endpoint.LibraryVersions(), endpoint.ByteStreamSettings()) + + param := datastore_ac_happy_home_designer_types.NewDataStoreGetMetaByOwnerIDParam() + + err := param.ExtractFrom(parametersStream) + if err != nil { + _, rmcError := protocol.GetMetaByOwnerID(fmt.Errorf("Failed to read param from parameters. %s", err.Error()), packet, callID, nil) + if rmcError != nil { + globals.RespondError(packet, ProtocolID, rmcError) + } + + return + } + + rmcMessage, rmcError := protocol.GetMetaByOwnerID(nil, packet, callID, param) + if rmcError != nil { + globals.RespondError(packet, ProtocolID, rmcError) + return + } + + globals.Respond(packet, rmcMessage) +} diff --git a/datastore/ac-happy-home-designer/get_meta_by_unique_id.go b/datastore/ac-happy-home-designer/get_meta_by_unique_id.go new file mode 100644 index 00000000..1e18d34d --- /dev/null +++ b/datastore/ac-happy-home-designer/get_meta_by_unique_id.go @@ -0,0 +1,47 @@ +// Package protocol implements the Animal Crossing: Happy Home Designer protocol +package protocol + +import ( + "fmt" + + "github.com/PretendoNetwork/nex-go/v2" + datastore_ac_happy_home_designer_types "github.com/PretendoNetwork/nex-protocols-go/v2/datastore/ac-happy-home-designer/types" + "github.com/PretendoNetwork/nex-protocols-go/v2/globals" +) + +func (protocol *Protocol) handleGetMetaByUniqueID(packet nex.PacketInterface) { + if protocol.GetMetaByUniqueID == nil { + err := nex.NewError(nex.ResultCodes.Core.NotImplemented, "DataStoreACHappyHomeDesigner::GetMetaByUniqueID not implemented") + + globals.Logger.Warning(err.Message) + globals.RespondError(packet, ProtocolID, err) + + return + } + + request := packet.RMCMessage() + callID := request.CallID + parameters := request.Parameters + endpoint := packet.Sender().Endpoint() + parametersStream := nex.NewByteStreamIn(parameters, endpoint.LibraryVersions(), endpoint.ByteStreamSettings()) + + param := datastore_ac_happy_home_designer_types.NewDataStoreGetMetaByUniqueIDParam() + + err := param.ExtractFrom(parametersStream) + if err != nil { + _, rmcError := protocol.GetMetaByUniqueID(fmt.Errorf("Failed to read param from parameters. %s", err.Error()), packet, callID, nil) + if rmcError != nil { + globals.RespondError(packet, ProtocolID, rmcError) + } + + return + } + + rmcMessage, rmcError := protocol.GetMetaByUniqueID(nil, packet, callID, param) + if rmcError != nil { + globals.RespondError(packet, ProtocolID, rmcError) + return + } + + globals.Respond(packet, rmcMessage) +} diff --git a/datastore/ac-happy-home-designer/get_object_infos.go b/datastore/ac-happy-home-designer/get_object_infos.go new file mode 100644 index 00000000..28677338 --- /dev/null +++ b/datastore/ac-happy-home-designer/get_object_infos.go @@ -0,0 +1,48 @@ +// Package protocol implements the Animal Crossing: Happy Home Designer protocol +package protocol + +import ( + "fmt" + + "github.com/PretendoNetwork/nex-go/v2" + "github.com/PretendoNetwork/nex-go/v2/types" + "github.com/PretendoNetwork/nex-protocols-go/v2/globals" +) + +func (protocol *Protocol) handleGetObjectInfos(packet nex.PacketInterface) { + if protocol.GetObjectInfos == nil { + err := nex.NewError(nex.ResultCodes.Core.NotImplemented, "DataStoreACHappyHomeDesigner::GetObjectInfos not implemented") + + globals.Logger.Warning(err.Message) + globals.RespondError(packet, ProtocolID, err) + + return + } + + request := packet.RMCMessage() + callID := request.CallID + parameters := request.Parameters + endpoint := packet.Sender().Endpoint() + parametersStream := nex.NewByteStreamIn(parameters, endpoint.LibraryVersions(), endpoint.ByteStreamSettings()) + + dataIDs := types.NewList[*types.PrimitiveU64]() + dataIDs.Type = types.NewPrimitiveU64(0) + + err := dataIDs.ExtractFrom(parametersStream) + if err != nil { + _, rmcError := protocol.GetObjectInfos(fmt.Errorf("Failed to read dataIDs from parameters. %s", err.Error()), packet, callID, nil) + if rmcError != nil { + globals.RespondError(packet, ProtocolID, rmcError) + } + + return + } + + rmcMessage, rmcError := protocol.GetObjectInfos(nil, packet, callID, dataIDs) + if rmcError != nil { + globals.RespondError(packet, ProtocolID, rmcError) + return + } + + globals.Respond(packet, rmcMessage) +} diff --git a/datastore/ac-happy-home-designer/protocol.go b/datastore/ac-happy-home-designer/protocol.go new file mode 100644 index 00000000..6016cc5e --- /dev/null +++ b/datastore/ac-happy-home-designer/protocol.go @@ -0,0 +1,152 @@ +// Package protocol implements the Animal Crossing: Happy Home Designer protocol +package protocol + +import ( + "fmt" + "slices" + + "github.com/PretendoNetwork/nex-go/v2" + "github.com/PretendoNetwork/nex-go/v2/types" + datastore "github.com/PretendoNetwork/nex-protocols-go/v2/datastore" + datastore_ac_happy_home_designer_types "github.com/PretendoNetwork/nex-protocols-go/v2/datastore/ac-happy-home-designer/types" + "github.com/PretendoNetwork/nex-protocols-go/v2/globals" +) + +const ( + // ProtocolID is the Protocol ID for the DataStore (Animal Crossing: Happy Home Designer) protocol. ID is the same as the DataStore protocol + ProtocolID = 0x73 + + // MethodGetObjectInfos is the method ID for GetObjectInfos + MethodGetObjectInfos = 0x2D + + // MethodGetMetaByOwnerID is the method ID for GetMetaByOwnerID + MethodGetMetaByOwnerID = 0x2E + + // MethodGetMetaByUniqueID is the method ID for GetMetaByUniqueID + MethodGetMetaByUniqueID = 0x2F + + // MethodSearchHouseNew is the method ID for SearchHouseNew + MethodSearchHouseNew = 0x30 + + // MethodSearchHousePopular is the method ID for SearchHousePopular + MethodSearchHousePopular = 0x31 + + // MethodSearchHouseResident is the method ID for SearchHouseResident + MethodSearchHouseResident = 0x32 + + // MethodSearchHouseContest is the method ID for SearchHouseContest + MethodSearchHouseContest = 0x33 + + // MethodSearchHouseContestRandom is the method ID for SearchHouseContestRandom + MethodSearchHouseContestRandom = 0x34 + + // MethodAddToBufferQueue is the method ID for AddToBufferQueue + MethodAddToBufferQueue = 0x35 + + // MethodGetBufferQueue is the method ID for GetBufferQueue + MethodGetBufferQueue = 0x36 + + // MethodGetBufferQueues is the method ID for GetBufferQueues + MethodGetBufferQueues = 0x37 + + // MethodClearBufferQueues is the method ID for ClearBufferQueues + MethodClearBufferQueues = 0x38 + + // MethodGetContestEntryCount is the method ID for GetContestEntryCount + MethodGetContestEntryCount = 0x39 +) + +var patchedMethods = []uint32{ + MethodGetObjectInfos, + MethodGetMetaByOwnerID, + MethodGetMetaByUniqueID, + MethodSearchHouseNew, + MethodSearchHousePopular, + MethodSearchHouseResident, + MethodSearchHouseContest, + MethodSearchHouseContestRandom, + MethodAddToBufferQueue, + MethodGetBufferQueue, + MethodGetBufferQueues, + MethodClearBufferQueues, + MethodGetContestEntryCount, +} + +type dataStoreProtocol = datastore.Protocol + +// Protocol stores all the RMC method handlers for the DataStore (Animal Crossing: Happy Home Designer) protocol and listens for requests +// Embeds the DataStore protocol +type Protocol struct { + endpoint nex.EndpointInterface + dataStoreProtocol + GetObjectInfos func(err error, packet nex.PacketInterface, callID uint32, dataIDs *types.List[*types.PrimitiveU64]) (*nex.RMCMessage, *nex.Error) + GetMetaByOwnerID func(err error, packet nex.PacketInterface, callID uint32, param *datastore_ac_happy_home_designer_types.DataStoreGetMetaByOwnerIDParam) (*nex.RMCMessage, *nex.Error) + GetMetaByUniqueID func(err error, packet nex.PacketInterface, callID uint32, param *datastore_ac_happy_home_designer_types.DataStoreGetMetaByUniqueIDParam) (*nex.RMCMessage, *nex.Error) + SearchHouseNew func(err error, packet nex.PacketInterface, callID uint32, param *datastore_ac_happy_home_designer_types.DataStoreSearchHouseParam) (*nex.RMCMessage, *nex.Error) + SearchHousePopular func(err error, packet nex.PacketInterface, callID uint32, param *datastore_ac_happy_home_designer_types.DataStoreSearchHouseParam) (*nex.RMCMessage, *nex.Error) + SearchHouseResident func(err error, packet nex.PacketInterface, callID uint32, param *datastore_ac_happy_home_designer_types.DataStoreSearchHouseParam) (*nex.RMCMessage, *nex.Error) + SearchHouseContest func(err error, packet nex.PacketInterface, callID uint32, param *datastore_ac_happy_home_designer_types.DataStoreSearchHouseParam) (*nex.RMCMessage, *nex.Error) + SearchHouseContestRandom func(err error, packet nex.PacketInterface, callID uint32, param *datastore_ac_happy_home_designer_types.DataStoreSearchHouseParam) (*nex.RMCMessage, *nex.Error) + AddToBufferQueue func(err error, packet nex.PacketInterface, callID uint32, param *datastore_ac_happy_home_designer_types.BufferQueueParam, buffer *types.QBuffer) (*nex.RMCMessage, *nex.Error) + GetBufferQueue func(err error, packet nex.PacketInterface, callID uint32, param *datastore_ac_happy_home_designer_types.BufferQueueParam) (*nex.RMCMessage, *nex.Error) + GetBufferQueues func(err error, packet nex.PacketInterface, callID uint32, params *types.List[*datastore_ac_happy_home_designer_types.BufferQueueParam]) (*nex.RMCMessage, *nex.Error) + ClearBufferQueues func(err error, packet nex.PacketInterface, callID uint32, params *types.List[*datastore_ac_happy_home_designer_types.BufferQueueParam]) (*nex.RMCMessage, *nex.Error) + GetContestEntryCount func(err error, packet nex.PacketInterface, callID uint32, pEntries *types.PrimitiveU32) (*nex.RMCMessage, *nex.Error) +} + +// HandlePacket sends the packet to the correct RMC method handler +func (protocol *Protocol) HandlePacket(packet nex.PacketInterface) { + message := packet.RMCMessage() + + if !message.IsRequest || message.ProtocolID != ProtocolID { + return + } + + if !slices.Contains(patchedMethods, message.MethodID) { + protocol.dataStoreProtocol.HandlePacket(packet) + return + } + + switch message.MethodID { + case MethodGetObjectInfos: + protocol.handleGetObjectInfos(packet) + case MethodGetMetaByOwnerID: + protocol.handleGetMetaByOwnerID(packet) + case MethodGetMetaByUniqueID: + protocol.handleGetMetaByUniqueID(packet) + case MethodSearchHouseNew: + protocol.handleSearchHouseNew(packet) + case MethodSearchHousePopular: + protocol.handleSearchHousePopular(packet) + case MethodSearchHouseResident: + protocol.handleSearchHouseResident(packet) + case MethodSearchHouseContest: + protocol.handleSearchHouseContest(packet) + case MethodSearchHouseContestRandom: + protocol.handleSearchHouseContestRandom(packet) + case MethodAddToBufferQueue: + protocol.handleAddToBufferQueue(packet) + case MethodGetBufferQueue: + protocol.handleGetBufferQueue(packet) + case MethodGetBufferQueues: + protocol.handleGetBufferQueues(packet) + case MethodClearBufferQueues: + protocol.handleClearBufferQueues(packet) + case MethodGetContestEntryCount: + protocol.handleGetContestEntryCount(packet) + default: + errMessage := fmt.Sprintf("Unsupported DataStoreHappyHomeDesigner method ID: %#v\n", message.MethodID) + err := nex.NewError(nex.ResultCodes.Core.NotImplemented, errMessage) + + globals.RespondError(packet, ProtocolID, err) + globals.Logger.Warning(err.Message) + } +} + +// NewProtocol returns a new DataStore (Animal Crossing: Happy Home Designer) protocol +func NewProtocol(endpoint nex.EndpointInterface) *Protocol { + protocol := &Protocol{endpoint: endpoint} + protocol.dataStoreProtocol.SetEndpoint(endpoint) + + return protocol +} diff --git a/datastore/ac-happy-home-designer/search_house_contest.go b/datastore/ac-happy-home-designer/search_house_contest.go new file mode 100644 index 00000000..845d80d7 --- /dev/null +++ b/datastore/ac-happy-home-designer/search_house_contest.go @@ -0,0 +1,47 @@ +// Package protocol implements the Animal Crossing: Happy Home Designer protocol +package protocol + +import ( + "fmt" + + "github.com/PretendoNetwork/nex-go/v2" + datastore_ac_happy_home_designer_types "github.com/PretendoNetwork/nex-protocols-go/v2/datastore/ac-happy-home-designer/types" + "github.com/PretendoNetwork/nex-protocols-go/v2/globals" +) + +func (protocol *Protocol) handleSearchHouseContest(packet nex.PacketInterface) { + if protocol.SearchHouseContest == nil { + err := nex.NewError(nex.ResultCodes.Core.NotImplemented, "DataStoreACHappyHomeDesigner::SearchHouseContest not implemented") + + globals.Logger.Warning(err.Message) + globals.RespondError(packet, ProtocolID, err) + + return + } + + request := packet.RMCMessage() + callID := request.CallID + parameters := request.Parameters + endpoint := packet.Sender().Endpoint() + parametersStream := nex.NewByteStreamIn(parameters, endpoint.LibraryVersions(), endpoint.ByteStreamSettings()) + + param := datastore_ac_happy_home_designer_types.NewDataStoreSearchHouseParam() + + err := param.ExtractFrom(parametersStream) + if err != nil { + _, rmcError := protocol.SearchHouseContest(fmt.Errorf("Failed to read param from parameters. %s", err.Error()), packet, callID, nil) + if rmcError != nil { + globals.RespondError(packet, ProtocolID, rmcError) + } + + return + } + + rmcMessage, rmcError := protocol.SearchHouseContest(nil, packet, callID, param) + if rmcError != nil { + globals.RespondError(packet, ProtocolID, rmcError) + return + } + + globals.Respond(packet, rmcMessage) +} diff --git a/datastore/ac-happy-home-designer/search_house_contest_random.go b/datastore/ac-happy-home-designer/search_house_contest_random.go new file mode 100644 index 00000000..a42034f3 --- /dev/null +++ b/datastore/ac-happy-home-designer/search_house_contest_random.go @@ -0,0 +1,47 @@ +// Package protocol implements the Animal Crossing: Happy Home Designer protocol +package protocol + +import ( + "fmt" + + "github.com/PretendoNetwork/nex-go/v2" + datastore_ac_happy_home_designer_types "github.com/PretendoNetwork/nex-protocols-go/v2/datastore/ac-happy-home-designer/types" + "github.com/PretendoNetwork/nex-protocols-go/v2/globals" +) + +func (protocol *Protocol) handleSearchHouseContestRandom(packet nex.PacketInterface) { + if protocol.SearchHouseContestRandom == nil { + err := nex.NewError(nex.ResultCodes.Core.NotImplemented, "DataStoreACHappyHomeDesigner::SearchHouseContestRandom not implemented") + + globals.Logger.Warning(err.Message) + globals.RespondError(packet, ProtocolID, err) + + return + } + + request := packet.RMCMessage() + callID := request.CallID + parameters := request.Parameters + endpoint := packet.Sender().Endpoint() + parametersStream := nex.NewByteStreamIn(parameters, endpoint.LibraryVersions(), endpoint.ByteStreamSettings()) + + param := datastore_ac_happy_home_designer_types.NewDataStoreSearchHouseParam() + + err := param.ExtractFrom(parametersStream) + if err != nil { + _, rmcError := protocol.SearchHouseContestRandom(fmt.Errorf("Failed to read param from parameters. %s", err.Error()), packet, callID, nil) + if rmcError != nil { + globals.RespondError(packet, ProtocolID, rmcError) + } + + return + } + + rmcMessage, rmcError := protocol.SearchHouseContestRandom(nil, packet, callID, param) + if rmcError != nil { + globals.RespondError(packet, ProtocolID, rmcError) + return + } + + globals.Respond(packet, rmcMessage) +} diff --git a/datastore/ac-happy-home-designer/search_house_new.go b/datastore/ac-happy-home-designer/search_house_new.go new file mode 100644 index 00000000..5b206d61 --- /dev/null +++ b/datastore/ac-happy-home-designer/search_house_new.go @@ -0,0 +1,47 @@ +// Package protocol implements the Animal Crossing: Happy Home Designer protocol +package protocol + +import ( + "fmt" + + "github.com/PretendoNetwork/nex-go/v2" + datastore_ac_happy_home_designer_types "github.com/PretendoNetwork/nex-protocols-go/v2/datastore/ac-happy-home-designer/types" + "github.com/PretendoNetwork/nex-protocols-go/v2/globals" +) + +func (protocol *Protocol) handleSearchHouseNew(packet nex.PacketInterface) { + if protocol.SearchHouseNew == nil { + err := nex.NewError(nex.ResultCodes.Core.NotImplemented, "DataStoreACHappyHomeDesigner::SearchHouseNew not implemented") + + globals.Logger.Warning(err.Message) + globals.RespondError(packet, ProtocolID, err) + + return + } + + request := packet.RMCMessage() + callID := request.CallID + parameters := request.Parameters + endpoint := packet.Sender().Endpoint() + parametersStream := nex.NewByteStreamIn(parameters, endpoint.LibraryVersions(), endpoint.ByteStreamSettings()) + + param := datastore_ac_happy_home_designer_types.NewDataStoreSearchHouseParam() + + err := param.ExtractFrom(parametersStream) + if err != nil { + _, rmcError := protocol.SearchHouseNew(fmt.Errorf("Failed to read param from parameters. %s", err.Error()), packet, callID, nil) + if rmcError != nil { + globals.RespondError(packet, ProtocolID, rmcError) + } + + return + } + + rmcMessage, rmcError := protocol.SearchHouseNew(nil, packet, callID, param) + if rmcError != nil { + globals.RespondError(packet, ProtocolID, rmcError) + return + } + + globals.Respond(packet, rmcMessage) +} diff --git a/datastore/ac-happy-home-designer/search_house_popular.go b/datastore/ac-happy-home-designer/search_house_popular.go new file mode 100644 index 00000000..7c07c41a --- /dev/null +++ b/datastore/ac-happy-home-designer/search_house_popular.go @@ -0,0 +1,47 @@ +// Package protocol implements the Animal Crossing: Happy Home Designer protocol +package protocol + +import ( + "fmt" + + "github.com/PretendoNetwork/nex-go/v2" + datastore_ac_happy_home_designer_types "github.com/PretendoNetwork/nex-protocols-go/v2/datastore/ac-happy-home-designer/types" + "github.com/PretendoNetwork/nex-protocols-go/v2/globals" +) + +func (protocol *Protocol) handleSearchHousePopular(packet nex.PacketInterface) { + if protocol.SearchHousePopular == nil { + err := nex.NewError(nex.ResultCodes.Core.NotImplemented, "DataStoreACHappyHomeDesigner::SearchHousePopular not implemented") + + globals.Logger.Warning(err.Message) + globals.RespondError(packet, ProtocolID, err) + + return + } + + request := packet.RMCMessage() + callID := request.CallID + parameters := request.Parameters + endpoint := packet.Sender().Endpoint() + parametersStream := nex.NewByteStreamIn(parameters, endpoint.LibraryVersions(), endpoint.ByteStreamSettings()) + + param := datastore_ac_happy_home_designer_types.NewDataStoreSearchHouseParam() + + err := param.ExtractFrom(parametersStream) + if err != nil { + _, rmcError := protocol.SearchHousePopular(fmt.Errorf("Failed to read param from parameters. %s", err.Error()), packet, callID, nil) + if rmcError != nil { + globals.RespondError(packet, ProtocolID, rmcError) + } + + return + } + + rmcMessage, rmcError := protocol.SearchHousePopular(nil, packet, callID, param) + if rmcError != nil { + globals.RespondError(packet, ProtocolID, rmcError) + return + } + + globals.Respond(packet, rmcMessage) +} diff --git a/datastore/ac-happy-home-designer/search_house_resident.go b/datastore/ac-happy-home-designer/search_house_resident.go new file mode 100644 index 00000000..87ff2bf0 --- /dev/null +++ b/datastore/ac-happy-home-designer/search_house_resident.go @@ -0,0 +1,47 @@ +// Package protocol implements the Animal Crossing: Happy Home Designer protocol +package protocol + +import ( + "fmt" + + "github.com/PretendoNetwork/nex-go/v2" + datastore_ac_happy_home_designer_types "github.com/PretendoNetwork/nex-protocols-go/v2/datastore/ac-happy-home-designer/types" + "github.com/PretendoNetwork/nex-protocols-go/v2/globals" +) + +func (protocol *Protocol) handleSearchHouseResident(packet nex.PacketInterface) { + if protocol.SearchHouseResident == nil { + err := nex.NewError(nex.ResultCodes.Core.NotImplemented, "DataStoreACHappyHomeDesigner::SearchHouseResident not implemented") + + globals.Logger.Warning(err.Message) + globals.RespondError(packet, ProtocolID, err) + + return + } + + request := packet.RMCMessage() + callID := request.CallID + parameters := request.Parameters + endpoint := packet.Sender().Endpoint() + parametersStream := nex.NewByteStreamIn(parameters, endpoint.LibraryVersions(), endpoint.ByteStreamSettings()) + + param := datastore_ac_happy_home_designer_types.NewDataStoreSearchHouseParam() + + err := param.ExtractFrom(parametersStream) + if err != nil { + _, rmcError := protocol.SearchHouseResident(fmt.Errorf("Failed to read param from parameters. %s", err.Error()), packet, callID, nil) + if rmcError != nil { + globals.RespondError(packet, ProtocolID, rmcError) + } + + return + } + + rmcMessage, rmcError := protocol.SearchHouseResident(nil, packet, callID, param) + if rmcError != nil { + globals.RespondError(packet, ProtocolID, rmcError) + return + } + + globals.Respond(packet, rmcMessage) +} diff --git a/datastore/ac-happy-home-designer/types/buffer_queue_param.go b/datastore/ac-happy-home-designer/types/buffer_queue_param.go new file mode 100644 index 00000000..48a0abe4 --- /dev/null +++ b/datastore/ac-happy-home-designer/types/buffer_queue_param.go @@ -0,0 +1,108 @@ +// Package types implements all the types used by the DataStoreACHappyHomeDesigner protocol +package types + +import ( + "fmt" + "strings" + + "github.com/PretendoNetwork/nex-go/v2/types" +) + +// BufferQueueParam is a type within the DataStoreACHappyHomeDesigner protocol +type BufferQueueParam struct { + types.Structure + + DataID *types.PrimitiveU64 + Slot *types.PrimitiveU32 +} + +// WriteTo writes the BufferQueueParam to the given variable +func (bqp *BufferQueueParam) WriteTo(writable types.Writable) { + contentWritable := writable.CopyNew() + + bqp.DataID.WriteTo(contentWritable) + bqp.Slot.WriteTo(contentWritable) + + content := contentWritable.Bytes() + + bqp.WriteHeaderTo(writable, uint32(len(content))) + + writable.Write(content) +} + +// ExtractFrom extracts the BufferQueueParam from the given readable +func (bqp *BufferQueueParam) ExtractFrom(readable types.Readable) error { + var err error + + err = bqp.ExtractHeaderFrom(readable) + if err != nil { + return fmt.Errorf("Failed to extract BufferQueueParam header. %s", err.Error()) + } + + err = bqp.DataID.ExtractFrom(readable) + if err != nil { + return fmt.Errorf("Failed to extract BufferQueueParam.DataID. %s", err.Error()) + } + + err = bqp.Slot.ExtractFrom(readable) + if err != nil { + return fmt.Errorf("Failed to extract BufferQueueParam.Slot. %s", err.Error()) + } + + return nil +} + +// Copy returns a new copied instance of DataStoreFileServerGetObject +func (bqp *BufferQueueParam) Copy() types.RVType { + copied := NewBufferQueueParam() + + copied.DataID = bqp.DataID + copied.Slot = bqp.Slot + + return copied +} + +// Equals checks if the given BufferQueueParam contains the same data as the current BufferQueueParam +func (bqp *BufferQueueParam) Equals(o types.RVType) bool { + if _, ok := o.(*BufferQueueParam); !ok { + return false + } + + other := o.(*BufferQueueParam) + + if !bqp.DataID.Equals(other.DataID) { + return false + } + + return bqp.Slot.Equals(other.Slot) +} + +// String returns the string representation of the BufferQueueParam +func (bqp *BufferQueueParam) String() string { + return bqp.FormatToString(0) +} + +// FormatToString pretty-prints the BufferQueueParam using the provided indentation level +func (bqp *BufferQueueParam) FormatToString(indentationLevel int) string { + indentationValues := strings.Repeat("\t", indentationLevel+1) + indentationEnd := strings.Repeat("\t", indentationLevel) + + var b strings.Builder + + b.WriteString("BufferQueueParam{\n") + b.WriteString(fmt.Sprintf("%sDataID: %s,\n", indentationValues, bqp.DataID)) + b.WriteString(fmt.Sprintf("%sSlot: %s,\n", indentationValues, bqp.Slot)) + b.WriteString(fmt.Sprintf("%s}", indentationEnd)) + + return b.String() +} + +// NewBufferQueueParam returns a new BufferQueueParam +func NewBufferQueueParam() *BufferQueueParam { + bqp := &BufferQueueParam{ + DataID: types.NewPrimitiveU64(0), + Slot: types.NewPrimitiveU32(0), + } + + return bqp +} diff --git a/datastore/ac-happy-home-designer/types/data_store_file_server_object_info.go b/datastore/ac-happy-home-designer/types/data_store_file_server_object_info.go new file mode 100644 index 00000000..23f6c8c8 --- /dev/null +++ b/datastore/ac-happy-home-designer/types/data_store_file_server_object_info.go @@ -0,0 +1,109 @@ +// Package types implements all the types used by the DataStoreACHappyHomeDesigner protocol +package types + +import ( + "fmt" + "strings" + + "github.com/PretendoNetwork/nex-go/v2/types" + datastore_types "github.com/PretendoNetwork/nex-protocols-go/v2/datastore/types" +) + +// DataStoreFileServerObjectInfo is a type within the DataStoreACHappyHomeDesigner protocol +type DataStoreFileServerObjectInfo struct { + types.Structure + + DataID *types.PrimitiveU64 + GetInfo *datastore_types.DataStoreReqGetInfo +} + +// WriteTo writes the DataStoreFileServerObjectInfo to the given variable +func (dsfsoi *DataStoreFileServerObjectInfo) WriteTo(writable types.Writable) { + contentWritable := writable.CopyNew() + + dsfsoi.DataID.WriteTo(contentWritable) + dsfsoi.GetInfo.WriteTo(contentWritable) + + content := contentWritable.Bytes() + + dsfsoi.WriteHeaderTo(writable, uint32(len(content))) + + writable.Write(content) +} + +// ExtractFrom extracts the DataStoreFileServerObjectInfo from the given readable +func (dsfsoi *DataStoreFileServerObjectInfo) ExtractFrom(readable types.Readable) error { + var err error + + err = dsfsoi.ExtractHeaderFrom(readable) + if err != nil { + return fmt.Errorf("Failed to extract DataStoreFileServerObjectInfo header. %s", err.Error()) + } + + err = dsfsoi.DataID.ExtractFrom(readable) + if err != nil { + return fmt.Errorf("Failed to extract DataStoreFileServerObjectInfo.DataID. %s", err.Error()) + } + + err = dsfsoi.GetInfo.ExtractFrom(readable) + if err != nil { + return fmt.Errorf("Failed to extract DataStoreFileServerObjectInfo.GetInfo. %s", err.Error()) + } + + return nil +} + +// Copy returns a new copied instance of DataStoreFileServerGetObject +func (dsfsoi *DataStoreFileServerObjectInfo) Copy() types.RVType { + copied := NewDataStoreFileServerObjectInfo() + + copied.DataID = dsfsoi.DataID + copied.GetInfo = dsfsoi.GetInfo + + return copied +} + +// Equals checks if the given DataStoreFileServerObjectInfo contains the same data as the current DataStoreFileServerObjectInfo +func (dsfsoi *DataStoreFileServerObjectInfo) Equals(o types.RVType) bool { + if _, ok := o.(*DataStoreFileServerObjectInfo); !ok { + return false + } + + other := o.(*DataStoreFileServerObjectInfo) + + if !dsfsoi.DataID.Equals(other.DataID) { + return false + } + + return dsfsoi.GetInfo.Equals(other.GetInfo) +} + +// String returns the string representation of the DataStoreFileServerObjectInfo +func (dsfsoi *DataStoreFileServerObjectInfo) String() string { + return dsfsoi.FormatToString(0) +} + +// FormatToString pretty-prints the DataStoreFileServerObjectInfo using the provided indentation level +func (dsfsoi *DataStoreFileServerObjectInfo) FormatToString(indentationLevel int) string { + indentationValues := strings.Repeat("\t", indentationLevel+1) + indentationEnd := strings.Repeat("\t", indentationLevel) + + var b strings.Builder + + b.WriteString("DataStoreFileServerObjectInfo{\n") + b.WriteString(fmt.Sprintf("%sDataID: %s,\n", indentationValues, dsfsoi.DataID)) + b.WriteString(fmt.Sprintf("%sGetInfo: %s,\n", indentationValues, dsfsoi.GetInfo.FormatToString(indentationLevel+1))) + b.WriteString(fmt.Sprintf("%s}", indentationEnd)) + + return b.String() +} + +// NewDataStoreFileServerObjectInfo returns a new DataStoreFileServerObjectInfo +func NewDataStoreFileServerObjectInfo() *DataStoreFileServerObjectInfo { + dsfsoi := &DataStoreFileServerObjectInfo{ + DataID: types.NewPrimitiveU64(0), + GetInfo: datastore_types.NewDataStoreReqGetInfo(), + } + + return dsfsoi +} diff --git a/datastore/ac-happy-home-designer/types/data_store_get_meta_by_owner_id_param.go b/datastore/ac-happy-home-designer/types/data_store_get_meta_by_owner_id_param.go new file mode 100644 index 00000000..4c3c28e7 --- /dev/null +++ b/datastore/ac-happy-home-designer/types/data_store_get_meta_by_owner_id_param.go @@ -0,0 +1,135 @@ +// Package types implements all the types used by the DataStoreACHappyHomeDesigner protocol +package types + +import ( + "fmt" + "strings" + + "github.com/PretendoNetwork/nex-go/v2/types" +) + +// DataStoreGetMetaByOwnerIDParam is a type within the DataStoreACHappyHomeDesigner protocol +type DataStoreGetMetaByOwnerIDParam struct { + types.Structure + OwnerIDs *types.List[*types.PrimitiveU32] + DataTypes *types.List[*types.PrimitiveU16] + ResultOption *types.PrimitiveU8 + ResultRange *types.ResultRange +} + +// WriteTo writes the DataStoreGetMetaByOwnerIDParam to the given variable +func (dsgmboip *DataStoreGetMetaByOwnerIDParam) WriteTo(writable types.Writable) { + contentWritable := writable.CopyNew() + + dsgmboip.OwnerIDs.WriteTo(contentWritable) + dsgmboip.DataTypes.WriteTo(contentWritable) + dsgmboip.ResultOption.WriteTo(contentWritable) + dsgmboip.ResultRange.WriteTo(contentWritable) + + content := contentWritable.Bytes() + + dsgmboip.WriteHeaderTo(writable, uint32(len(content))) + + writable.Write(content) +} + +// ExtractFrom extracts the DataStoreGetMetaByOwnerIDParam from the given readable +func (dsgmboip *DataStoreGetMetaByOwnerIDParam) ExtractFrom(readable types.Readable) error { + var err error + + err = dsgmboip.ExtractHeaderFrom(readable) + if err != nil { + return fmt.Errorf("Failed to extract DataStoreGetMetaByOwnerIDParam header. %s", err.Error()) + } + + err = dsgmboip.OwnerIDs.ExtractFrom(readable) + if err != nil { + return fmt.Errorf("Failed to extract DataStoreGetMetaByOwnerIDParam.OwnerIDs. %s", err.Error()) + } + + err = dsgmboip.DataTypes.ExtractFrom(readable) + if err != nil { + return fmt.Errorf("Failed to extract DataStoreGetMetaByOwnerIDParam.DataTypes. %s", err.Error()) + } + + err = dsgmboip.ResultOption.ExtractFrom(readable) + if err != nil { + return fmt.Errorf("Failed to extract DataStoreGetMetaByOwnerIDParam.ResultOption. %s", err.Error()) + } + + err = dsgmboip.ResultRange.ExtractFrom(readable) + if err != nil { + return fmt.Errorf("Failed to extract DataStoreGetMetaByOwnerIDParam.ResultRange. %s", err.Error()) + } + + return nil +} + +// Copy returns a new copied instance of DataStoreFileServerGetObject +func (dsgmboip *DataStoreGetMetaByOwnerIDParam) Copy() types.RVType { + copied := NewDataStoreGetMetaByOwnerIDParam() + + copied.OwnerIDs = dsgmboip.OwnerIDs + copied.DataTypes = dsgmboip.DataTypes + copied.ResultOption = dsgmboip.ResultOption + copied.ResultRange = dsgmboip.ResultRange + + return copied +} + +// Equals checks if the given DataStoreGetMetaByOwnerIDParam contains the same data as the current DataStoreGetMetaByOwnerIDParam +func (dsgmboip *DataStoreGetMetaByOwnerIDParam) Equals(o types.RVType) bool { + if _, ok := o.(*DataStoreGetMetaByOwnerIDParam); !ok { + return false + } + + other := o.(*DataStoreGetMetaByOwnerIDParam) + + if !dsgmboip.OwnerIDs.Equals(other.OwnerIDs) { + return false + } + + if !dsgmboip.DataTypes.Equals(other.DataTypes) { + return false + } + + if !dsgmboip.ResultOption.Equals(other.ResultOption) { + return false + } + + return dsgmboip.ResultRange.Equals(other.ResultRange) +} + +// String returns the string representation of the DataStoreGetMetaByOwnerIDParam +func (dsgmboip *DataStoreGetMetaByOwnerIDParam) String() string { + return dsgmboip.FormatToString(0) +} + +// FormatToString pretty-prints the DataStoreGetMetaByOwnerIDParam using the provided indentation level +func (dsgmboip *DataStoreGetMetaByOwnerIDParam) FormatToString(indentationLevel int) string { + indentationValues := strings.Repeat("\t", indentationLevel+1) + indentationEnd := strings.Repeat("\t", indentationLevel) + + var b strings.Builder + + b.WriteString("DataStoreGetMetaByOwnerIDParam{\n") + b.WriteString(fmt.Sprintf("%sOwnerIDs: %s,\n", indentationValues, dsgmboip.OwnerIDs)) + b.WriteString(fmt.Sprintf("%sDataTypes: %s,\n", indentationValues, dsgmboip.DataTypes)) + b.WriteString(fmt.Sprintf("%sResultOption: %s,\n", indentationValues, dsgmboip.ResultOption)) + b.WriteString(fmt.Sprintf("%sResultRange: %s,\n", indentationValues, dsgmboip.ResultRange)) + b.WriteString(fmt.Sprintf("%s}", indentationEnd)) + + return b.String() +} + +// NewDataStoreGetMetaByOwnerIDParam returns a new DataStoreGetMetaByOwnerIDParam +func NewDataStoreGetMetaByOwnerIDParam() *DataStoreGetMetaByOwnerIDParam { + dsgmboip := &DataStoreGetMetaByOwnerIDParam{ + OwnerIDs: types.NewList[*types.PrimitiveU32](), + DataTypes: types.NewList[*types.PrimitiveU16](), + ResultOption: types.NewPrimitiveU8(0), + ResultRange: types.NewResultRange(), + } + + return dsgmboip +} diff --git a/datastore/ac-happy-home-designer/types/data_store_get_meta_by_unique_id_param.go b/datastore/ac-happy-home-designer/types/data_store_get_meta_by_unique_id_param.go new file mode 100644 index 00000000..e0a2239b --- /dev/null +++ b/datastore/ac-happy-home-designer/types/data_store_get_meta_by_unique_id_param.go @@ -0,0 +1,135 @@ +// Package types implements all the types used by the DataStoreACHappyHomeDesigner protocol +package types + +import ( + "fmt" + "strings" + + "github.com/PretendoNetwork/nex-go/v2/types" +) + +// DataStoreGetMetaByUniqueIDParam is a type within the DataStoreACHappyHomeDesigner protocol +type DataStoreGetMetaByUniqueIDParam struct { + types.Structure + UniqueIDs *types.List[*types.PrimitiveU32] + DataTypes *types.List[*types.PrimitiveU16] + ResultOption *types.PrimitiveU8 + ResultRange *types.ResultRange +} + +// WriteTo writes the DataStoreGetMetaByUniqueIDParam to the given variable +func (dsgmbuip *DataStoreGetMetaByUniqueIDParam) WriteTo(writable types.Writable) { + contentWritable := writable.CopyNew() + + dsgmbuip.UniqueIDs.WriteTo(contentWritable) + dsgmbuip.DataTypes.WriteTo(contentWritable) + dsgmbuip.ResultOption.WriteTo(contentWritable) + dsgmbuip.ResultRange.WriteTo(contentWritable) + + content := contentWritable.Bytes() + + dsgmbuip.WriteHeaderTo(writable, uint32(len(content))) + + writable.Write(content) +} + +// ExtractFrom extracts the DataStoreGetMetaByUniqueIDParam from the given readable +func (dsgmbuip *DataStoreGetMetaByUniqueIDParam) ExtractFrom(readable types.Readable) error { + var err error + + err = dsgmbuip.ExtractHeaderFrom(readable) + if err != nil { + return fmt.Errorf("Failed to extract DataStoreGetMetaByUniqueIDParam header. %s", err.Error()) + } + + err = dsgmbuip.UniqueIDs.ExtractFrom(readable) + if err != nil { + return fmt.Errorf("Failed to extract DataStoreGetMetaByUniqueIDParam.UniqueIDs. %s", err.Error()) + } + + err = dsgmbuip.DataTypes.ExtractFrom(readable) + if err != nil { + return fmt.Errorf("Failed to extract DataStoreGetMetaByUniqueIDParam.DataTypes. %s", err.Error()) + } + + err = dsgmbuip.ResultOption.ExtractFrom(readable) + if err != nil { + return fmt.Errorf("Failed to extract DataStoreGetMetaByUniqueIDParam.ResultOption. %s", err.Error()) + } + + err = dsgmbuip.ResultRange.ExtractFrom(readable) + if err != nil { + return fmt.Errorf("Failed to extract DataStoreGetMetaByUniqueIDParam.ResultRange. %s", err.Error()) + } + + return nil +} + +// Copy returns a new copied instance of DataStoreFileServerGetObject +func (dsgmbuip *DataStoreGetMetaByUniqueIDParam) Copy() types.RVType { + copied := NewDataStoreGetMetaByUniqueIDParam() + + copied.UniqueIDs = dsgmbuip.UniqueIDs + copied.DataTypes = dsgmbuip.DataTypes + copied.ResultOption = dsgmbuip.ResultOption + copied.ResultRange = dsgmbuip.ResultRange + + return copied +} + +// Equals checks if the given DataStoreGetMetaByUniqueIDParam contains the same data as the current DataStoreGetMetaByUniqueIDParam +func (dsgmbuip *DataStoreGetMetaByUniqueIDParam) Equals(o types.RVType) bool { + if _, ok := o.(*DataStoreGetMetaByUniqueIDParam); !ok { + return false + } + + other := o.(*DataStoreGetMetaByUniqueIDParam) + + if !dsgmbuip.UniqueIDs.Equals(other.UniqueIDs) { + return false + } + + if !dsgmbuip.DataTypes.Equals(other.DataTypes) { + return false + } + + if !dsgmbuip.ResultOption.Equals(other.ResultOption) { + return false + } + + return dsgmbuip.ResultRange.Equals(other.ResultRange) +} + +// String returns the string representation of the DataStoreGetMetaByUniqueIDParam +func (dsgmbuip *DataStoreGetMetaByUniqueIDParam) String() string { + return dsgmbuip.FormatToString(0) +} + +// FormatToString pretty-prints the DataStoreGetMetaByUniqueIDParam using the provided indentation level +func (dsgmbuip *DataStoreGetMetaByUniqueIDParam) FormatToString(indentationLevel int) string { + indentationValues := strings.Repeat("\t", indentationLevel+1) + indentationEnd := strings.Repeat("\t", indentationLevel) + + var b strings.Builder + + b.WriteString("DataStoreGetMetaByUniqueIDParam{\n") + b.WriteString(fmt.Sprintf("%sUniqueIDs: %s,\n", indentationValues, dsgmbuip.UniqueIDs)) + b.WriteString(fmt.Sprintf("%sDataTypes: %s,\n", indentationValues, dsgmbuip.DataTypes)) + b.WriteString(fmt.Sprintf("%sResultOption: %s,\n", indentationValues, dsgmbuip.ResultOption)) + b.WriteString(fmt.Sprintf("%sResultRange: %s,\n", indentationValues, dsgmbuip.ResultRange)) + b.WriteString(fmt.Sprintf("%s}", indentationEnd)) + + return b.String() +} + +// NewDataStoreGetMetaByUniqueIDParam returns a new DataStoreGetMetaByUniqueIDParam +func NewDataStoreGetMetaByUniqueIDParam() *DataStoreGetMetaByUniqueIDParam { + dsgmbuip := &DataStoreGetMetaByUniqueIDParam{ + UniqueIDs: types.NewList[*types.PrimitiveU32](), + DataTypes: types.NewList[*types.PrimitiveU16](), + ResultOption: types.NewPrimitiveU8(0), + ResultRange: types.NewResultRange(), + } + + return dsgmbuip +} diff --git a/datastore/ac-happy-home-designer/types/data_store_search_house_param.go b/datastore/ac-happy-home-designer/types/data_store_search_house_param.go new file mode 100644 index 00000000..0ff02ed7 --- /dev/null +++ b/datastore/ac-happy-home-designer/types/data_store_search_house_param.go @@ -0,0 +1,165 @@ +// Package types implements all the types used by the DataStoreACHappyHomeDesigner protocol +package types + +import ( + "fmt" + "strings" + + "github.com/PretendoNetwork/nex-go/v2/types" +) + +// DataStoreSearchHouseParam is a type within the DataStoreACHappyHomeDesigner protocol +type DataStoreSearchHouseParam struct { + types.Structure + + DataType *types.PrimitiveU16 + ResultOrderColumns *types.Buffer + ResultRange *types.ResultRange + ResultOption *types.PrimitiveU8 + Region *types.PrimitiveU8 + Country *types.PrimitiveU8 +} + +// WriteTo writes the DataStoreSearchHouseParam to the given variable +func (dsshp *DataStoreSearchHouseParam) WriteTo(writable types.Writable) { + contentWritable := writable.CopyNew() + + dsshp.DataType.WriteTo(contentWritable) + dsshp.ResultOrderColumns.WriteTo(contentWritable) + dsshp.ResultRange.WriteTo(contentWritable) + dsshp.ResultOption.WriteTo(contentWritable) + dsshp.Region.WriteTo(contentWritable) + dsshp.Country.WriteTo(contentWritable) + + content := contentWritable.Bytes() + + dsshp.WriteHeaderTo(writable, uint32(len(content))) + + writable.Write(content) +} + +// ExtractFrom extracts the DataStoreSearchHouseParam from the given readable +func (dsshp *DataStoreSearchHouseParam) ExtractFrom(readable types.Readable) error { + var err error + + err = dsshp.ExtractHeaderFrom(readable) + if err != nil { + return fmt.Errorf("Failed to extract DataStoreSearchHouseParam header. %s", err.Error()) + } + + err = dsshp.DataType.ExtractFrom(readable) + if err != nil { + return fmt.Errorf("Failed to extract DataStoreSearchHouseParam.DataType. %s", err.Error()) + } + + err = dsshp.ResultOrderColumns.ExtractFrom(readable) + if err != nil { + return fmt.Errorf("Failed to extract DataStoreSearchHouseParam.ResultOrderColumns. %s", err.Error()) + } + + err = dsshp.ResultRange.ExtractFrom(readable) + if err != nil { + return fmt.Errorf("Failed to extract DataStoreSearchHouseParam.ResultRange. %s", err.Error()) + } + + err = dsshp.ResultOption.ExtractFrom(readable) + if err != nil { + return fmt.Errorf("Failed to extract DataStoreSearchHouseParam.ResultOption. %s", err.Error()) + } + + err = dsshp.Region.ExtractFrom(readable) + if err != nil { + return fmt.Errorf("Failed to extract DataStoreSearchHouseParam.Region. %s", err.Error()) + } + + err = dsshp.Country.ExtractFrom(readable) + if err != nil { + return fmt.Errorf("Failed to extract DataStoreSearchHouseParam.Country. %s", err.Error()) + } + + return nil +} + +// Copy returns a new copied instance of DataStoreSearchHouseParam +func (dsshp *DataStoreSearchHouseParam) Copy() types.RVType { + copied := NewDataStoreSearchHouseParam() + + copied.DataType = dsshp.DataType + copied.ResultOrderColumns = dsshp.ResultOrderColumns + copied.ResultRange = dsshp.ResultRange + copied.ResultOption = dsshp.ResultOption + copied.Region = dsshp.Region + copied.Country = dsshp.Country + + return copied +} + +// Equals checks if the given DataStoreSearchHouseParam contains the same data as the current DataStoreSearchHouseParam +func (dsshp *DataStoreSearchHouseParam) Equals(o types.RVType) bool { + if _, ok := o.(*DataStoreSearchHouseParam); !ok { + return false + } + + other := o.(*DataStoreSearchHouseParam) + + if !dsshp.DataType.Equals(other.DataType) { + return false + } + + if !dsshp.ResultOrderColumns.Equals(other.ResultOrderColumns) { + return false + } + + if !dsshp.ResultRange.Equals(other.ResultRange) { + return false + } + + if !dsshp.ResultOption.Equals(other.ResultOption) { + return false + } + + if !dsshp.Region.Equals(other.Region) { + return false + } + + return dsshp.Country.Equals(other.Country) +} + +// String returns the string representation of the DataStoreSearchHouseParam +func (dsshp *DataStoreSearchHouseParam) String() string { + return dsshp.FormatToString(0) +} + +// FormatToString pretty-prints the DataStoreSearchHouseParam using the provided indentation level + +func (dsshp *DataStoreSearchHouseParam) FormatToString(indentationLevel int) string { + indentationValues := strings.Repeat("\t", indentationLevel+1) + indentationEnd := strings.Repeat("\t", indentationLevel) + + var b strings.Builder + + b.WriteString("DataStoreSearchHouseParam{\n") + b.WriteString(fmt.Sprintf("%sDataType: %s,\n", indentationValues, dsshp.DataType)) + b.WriteString(fmt.Sprintf("%sResultOrderColumns: %s,\n", indentationValues, dsshp.ResultOrderColumns)) + b.WriteString(fmt.Sprintf("%sResultRange: %s,\n", indentationValues, dsshp.ResultRange)) + b.WriteString(fmt.Sprintf("%sResultOption: %s,\n", indentationValues, dsshp.ResultOption)) + b.WriteString(fmt.Sprintf("%sRegion: %s,\n", indentationValues, dsshp.Region)) + b.WriteString(fmt.Sprintf("%sCountry: %s,\n", indentationValues, dsshp.Country)) + b.WriteString(fmt.Sprintf("%s}", indentationEnd)) + + return b.String() +} + +// NewDataStoreSearchHouseParam returns a new DataStoreSearchHouseParam +func NewDataStoreSearchHouseParam() *DataStoreSearchHouseParam { + dsshp := &DataStoreSearchHouseParam{ + DataType: types.NewPrimitiveU16(0), + ResultOrderColumns: types.NewBuffer(nil), + ResultRange: types.NewResultRange(), + ResultOption: types.NewPrimitiveU8(0), + Region: types.NewPrimitiveU8(0), + Country: types.NewPrimitiveU8(0), + } + + return dsshp +}