Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Animal Crossing: Happy Home Designer DataStore protocol #42

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions datastore/ac-happy-home-designer/add_to_buffer_queue.go
Original file line number Diff line number Diff line change
@@ -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)
}
49 changes: 49 additions & 0 deletions datastore/ac-happy-home-designer/clear_buffer_queues.go
Original file line number Diff line number Diff line change
@@ -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)
}
47 changes: 47 additions & 0 deletions datastore/ac-happy-home-designer/get_buffer_queue.go
Original file line number Diff line number Diff line change
@@ -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)
}
49 changes: 49 additions & 0 deletions datastore/ac-happy-home-designer/get_buffer_queues.go
Original file line number Diff line number Diff line change
@@ -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)
}
47 changes: 47 additions & 0 deletions datastore/ac-happy-home-designer/get_contest_entry_count.go
Original file line number Diff line number Diff line change
@@ -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)
}
47 changes: 47 additions & 0 deletions datastore/ac-happy-home-designer/get_meta_by_owner_id.go
Original file line number Diff line number Diff line change
@@ -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)
}
47 changes: 47 additions & 0 deletions datastore/ac-happy-home-designer/get_meta_by_unique_id.go
Original file line number Diff line number Diff line change
@@ -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)
}
Loading