Removing TODO comments, making issues for them (#807)

* removed the rest of the magic number errors from d2game

* hotfix for bug i added in map engine test

* removed TODO's from d2mapengine/engine.go, added link to github issue

* removed TODO's and made issues and other minor lint work

* lint cleanup, mostly removing TODO's and putting links to their issues on github
This commit is contained in:
gravestench 2020-10-25 14:21:14 +00:00 committed by GitHub
parent 18c9e85cbc
commit 589850a728
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 116 additions and 105 deletions

View File

@ -616,7 +616,7 @@ func (a *App) ToCreateGame(filePath string, connType d2clientconnectiontype.Clie
}
if err = gameClient.Open(host, filePath); err != nil {
// TODO an error screen should be shown in this case
// https://github.com/OpenDiablo2/OpenDiablo2/issues/805
fmt.Printf("can not connect to the host: %s", host)
}
@ -626,6 +626,7 @@ func (a *App) ToCreateGame(filePath string, connType d2clientconnectiontype.Clie
// ToCharacterSelect forces the game to transition to the Character Select (load character) screen
func (a *App) ToCharacterSelect(connType d2clientconnectiontype.ClientConnectionType, connHost string) {
// https://github.com/OpenDiablo2/OpenDiablo2/issues/790
characterSelect := d2gamescreen.CreateCharacterSelect(a, a.asset, a.renderer, a.inputManager,
a.audio, a.ui, connType, connHost)

View File

@ -0,0 +1,9 @@
package d2enum
type ArmorClass string
const (
ArmorClassLite = "lit"
ArmorClassMedium = "med"
ArmorClassHeavy = "hvy"
)

View File

@ -24,6 +24,7 @@ type InventoryItemFactory struct {
// LoadHeroObjects loads the equipment objects of the hero
func (f *InventoryItemFactory) loadHeroObjects() {
// https://github.com/OpenDiablo2/OpenDiablo2/issues/795
//Mode: d2enum.AnimationModePlayerNeutral.String(),
//Base: "/data/global/chars",
f.DefaultHeroItems = map[d2enum.Hero]CharacterEquipment{
@ -69,7 +70,7 @@ func (f *InventoryItemFactory) GetArmorItemByCode(code string) *InventoryItemArm
InventorySizeY: result.InventoryHeight,
ItemName: result.Name,
ItemCode: result.Code,
ArmorClass: "lit", // TODO: Where does this come from?
ArmorClass: d2enum.ArmorClassLite, // comes from ArmType.txt
}
}
@ -90,7 +91,7 @@ func (f *InventoryItemFactory) GetMiscItemByCode(code string) *InventoryItemMisc
// GetWeaponItemByCode returns the weapon item for the given code
func (f *InventoryItemFactory) GetWeaponItemByCode(code string) *InventoryItemWeapon {
// TODO: Non-normal codes will fail here...
// https://github.com/OpenDiablo2/OpenDiablo2/issues/796
result := f.asset.Records.Item.Weapons[code]
if result == nil {
log.Fatalf("Could not find weapon entry for code '%s'", code)

View File

@ -31,7 +31,8 @@ type MapEngine struct {
startSubTileX int // Starting X position
startSubTileY int // Starting Y position
dt1Files []string // List of DS1 strings
// TODO: remove this flag and show loading screen until the initial server packets are handled and the map is generated (only for remote client)
// https://github.com/OpenDiablo2/OpenDiablo2/issues/789
IsLoading bool // (temp) Whether we have processed the GenerateMapPacket(only for remote client)
}
@ -201,11 +202,6 @@ func (m *MapEngine) tileCoordinateToIndex(x, y int) int {
return x + (y * m.size.Width)
}
// tileIndexToCoordinate converts tile index from MapEngine.tiles to x,y coordinate
func (m *MapEngine) tileIndexToCoordinate(index int) (x, y int) {
return index % m.size.Width, index / m.size.Width
}
// SubTileAt gets the flags for the given subtile
func (m *MapEngine) SubTileAt(subX, subY int) *d2dt1.SubTileFlags {
tile := m.TileAt(subX/subtilesPerTile, subY/subtilesPerTile)
@ -294,9 +290,8 @@ func (m *MapEngine) GetCenterPosition() (x, y float64) {
// Advance calls the Advance() method for all entities,
// processing a single tick.
func (m *MapEngine) Advance(tickTime float64) {
// TODO:(temp hack) prevents concurrent map read & write exceptions that occur when we join a TCP game as a remote client
// due to the engine updating entities before handling the GenerateMapPacket
if m.IsLoading {
// https://github.com/OpenDiablo2/OpenDiablo2/issues/789
return
}

View File

@ -96,7 +96,7 @@ func (f *MapEntityFactory) NewPlayer(id, name string, x, y, direction int, heroT
Equipment: equipment,
Stats: heroState.Stats,
Skills: heroState.Skills,
//TODO: active left & right skill should be loaded from save file instead
// https://github.com/OpenDiablo2/OpenDiablo2/issues/799
LeftSkill: heroState.Skills[attackSkillID],
RightSkill: heroState.Skills[attackSkillID],
name: name,
@ -108,7 +108,7 @@ func (f *MapEntityFactory) NewPlayer(id, name string, x, y, direction int, heroT
}
result.mapEntity.uuid = id
//TODO: should be based on Player.isRunning after we store isRunning in the save file
// https://github.com/OpenDiablo2/OpenDiablo2/issues/799
result.SetSpeed(baseWalkSpeed)
result.mapEntity.directioner = result.rotate
err = composite.SetMode(d2enum.PlayerAnimationModeTownNeutral, equipment.RightHand.GetWeaponClass())
@ -184,6 +184,7 @@ func (f *MapEntityFactory) NewItem(x, y int, codes ...string) (*Item, error) {
// NewNPC creates a new NPC and returns a pointer to it.
func (f *MapEntityFactory) NewNPC(x, y int, monstat *d2records.MonStatsRecord, direction int) (*NPC, error) {
// https://github.com/OpenDiablo2/OpenDiablo2/issues/803
result := &NPC{
mapEntity: newMapEntity(x, y),
HasPaths: false,
@ -239,12 +240,12 @@ func (f *MapEntityFactory) NewCastOverlay(x, y int, overlayRecord *d2records.Ove
return nil, err
}
// TODO: Frame index and played count seem to be shared across the cloned animation objects when we retrieve the animation from the asset manager cache.
// https://github.com/OpenDiablo2/OpenDiablo2/issues/767
animation.Rewind()
animation.ResetPlayedCount()
animationSpeed := float64(overlayRecord.AnimRate*retailFps) / millisecondsPerSecond
playLoop := false // TODO: should be based on the overlay record, some overlays can repeat(e.g. Bone Shield, Frozen Armor)
playLoop := false // https://github.com/OpenDiablo2/OpenDiablo2/issues/804
animation.SetPlayLength(animationSpeed)
animation.SetPlayLoop(playLoop)

View File

@ -68,7 +68,8 @@ func CreateCharacterSelect(
connectionType d2clientconnectiontype.ClientConnectionType,
connectionHost string,
) *CharacterSelect {
playerStateFactory, _ := d2hero.NewHeroStateFactory(asset) // TODO: handle errors
// https://github.com/OpenDiablo2/OpenDiablo2/issues/790
playerStateFactory, _ := d2hero.NewHeroStateFactory(asset)
entityFactory, _ := d2mapentity.NewMapEntityFactory(asset)
return &CharacterSelect{
@ -142,11 +143,10 @@ const (
// OnLoad loads the resources for the Character Select screen
func (v *CharacterSelect) OnLoad(loading d2screen.LoadingState) {
var err error
v.audioProvider.PlayBGM(d2resource.BGMTitle)
if err := v.inputManager.BindHandler(v); err != nil {
err := v.inputManager.BindHandler(v)
if err != nil {
fmt.Println("failed to add Character Select screen as event handler")
}
@ -315,7 +315,7 @@ func (v *CharacterSelect) updateCharacterBoxes() {
heroType := v.gameStates[idx].HeroType
equipment := v.DefaultHeroItems[heroType]
// TODO: Generate or load the object from the actual player data...
// https://github.com/OpenDiablo2/OpenDiablo2/issues/791
v.characterImage[i] = v.NewPlayer("", "", 0, 0, 0,
v.gameStates[idx].HeroType,
v.gameStates[idx].Stats,
@ -396,51 +396,53 @@ func (v *CharacterSelect) moveSelectionBox() {
// OnMouseButtonDown is called when a mouse button is clicked
func (v *CharacterSelect) OnMouseButtonDown(event d2interface.MouseEvent) bool {
if !v.showDeleteConfirmation {
if event.Button() == d2enum.MouseButtonLeft {
mx, my := event.X(), event.Y()
bw := selectionBoxWidth
bh := selectionBoxHeight
localMouseX := mx - selectionBoxOffsetX
localMouseY := my - selectionBoxOffsetY
// if Mouse is within character selection bounds.
if localMouseX > 0 && localMouseX < bw*2 && localMouseY >= 0 && localMouseY < bh*4 {
adjustY := localMouseY / bh
// sets current verticle index for selected character in left column.
selectedIndex := adjustY * selectionBoxNumColumns
// if selected character in left column should be in right column, add 1.
if localMouseX > bw {
selectedIndex++
}
// Make sure selection takes the scrollbar into account to make proper selection.
if (v.charScrollbar.GetCurrentOffset()*2)+selectedIndex < len(v.gameStates) {
selectedIndex = (v.charScrollbar.GetCurrentOffset() * 2) + selectedIndex
}
// if the selection box didn't move, check if it was a double click, otherwise set selectedCharacter to
// selectedIndex and move selection box over both.
if v.selectedCharacter == selectedIndex {
// We clicked twice within character selection box within v.doubleClickTime seconds.
if (v.tickTimer - v.storedTickTimer) < doubleClickTime {
v.onOkButtonClicked()
}
} else if selectedIndex < len(v.gameStates) {
v.selectedCharacter = selectedIndex
v.moveSelectionBox()
}
// Keep track of when we last clicked so we can determine if we double clicked a character.
v.storedTickTimer = v.tickTimer
}
return true
}
if v.showDeleteConfirmation {
return false
}
return false
if event.Button() != d2enum.MouseButtonLeft {
return false
}
mx, my := event.X(), event.Y()
bw := selectionBoxWidth
bh := selectionBoxHeight
localMouseX := mx - selectionBoxOffsetX
localMouseY := my - selectionBoxOffsetY
// if Mouse is within character selection bounds.
if localMouseX > 0 && localMouseX < bw*2 && localMouseY >= 0 && localMouseY < bh*4 {
adjustY := localMouseY / bh
// sets current verticle index for selected character in left column.
selectedIndex := adjustY * selectionBoxNumColumns
// if selected character in left column should be in right column, add 1.
if localMouseX > bw {
selectedIndex++
}
// Make sure selection takes the scrollbar into account to make proper selection.
if (v.charScrollbar.GetCurrentOffset()*2)+selectedIndex < len(v.gameStates) {
selectedIndex = (v.charScrollbar.GetCurrentOffset() * 2) + selectedIndex
}
// if the selection box didn't move, check if it was a double click, otherwise set selectedCharacter to
// selectedIndex and move selection box over both.
if v.selectedCharacter == selectedIndex {
// We clicked twice within character selection box within v.doubleClickTime seconds.
if (v.tickTimer - v.storedTickTimer) < doubleClickTime {
v.onOkButtonClicked()
}
} else if selectedIndex < len(v.gameStates) {
v.selectedCharacter = selectedIndex
v.moveSelectionBox()
}
// Keep track of when we last clicked so we can determine if we double clicked a character.
v.storedTickTimer = v.tickTimer
}
return true
}
// Advance runs the update logic on the Character Select screen
@ -515,7 +517,8 @@ func (v *CharacterSelect) onOkButtonClicked() {
// OnUnload candles cleanup when this screen is closed
func (v *CharacterSelect) OnUnload() error {
if err := v.inputManager.UnbindHandler(v); err != nil { // TODO: hack
// https://github.com/OpenDiablo2/OpenDiablo2/issues/792
if err := v.inputManager.UnbindHandler(v); err != nil {
return err
}

View File

@ -63,7 +63,6 @@ func CreateCredits(navigator d2interface.Navigator, asset *d2asset.AssetManager,
}
// LoadContributors loads the contributors data from file
// TODO: use markdown for file and convert it to the suitable format
func (v *Credits) LoadContributors() []string {
file, err := os.Open(path.Join("./", "CONTRIBUTORS"))
if err != nil || file == nil {

View File

@ -42,7 +42,7 @@ type Game struct {
gameClient *d2client.GameClient
mapRenderer *d2maprenderer.MapRenderer
uiManager *d2ui.UIManager
gameControls *d2player.GameControls // TODO: Hack
gameControls *d2player.GameControls
localPlayer *d2mapentity.Player
lastRegionType d2enum.RegionIdType
ticksSinceLevelCheck float64
@ -152,9 +152,9 @@ func (v *Game) OnLoad(_ d2screen.LoadingState) {
return
}
monster, err := v.gameClient.MapEngine.NewNPC(x, y, monstat, 0)
if err != nil {
v.terminal.OutputErrorf("error generating monster \"%s\": %v", name, err)
monster, npcErr := v.gameClient.MapEngine.NewNPC(x, y, monstat, 0)
if npcErr != nil {
v.terminal.OutputErrorf("error generating monster \"%s\": %v", name, npcErr)
return
}
@ -168,11 +168,13 @@ func (v *Game) OnLoad(_ d2screen.LoadingState) {
// OnUnload releases the resources of Gameplay screen
func (v *Game) OnUnload() error {
if err := v.inputManager.UnbindHandler(v.gameControls); err != nil { // TODO: hack
// https://github.com/OpenDiablo2/OpenDiablo2/issues/792
if err := v.inputManager.UnbindHandler(v.gameControls); err != nil {
return err
}
if err := v.inputManager.UnbindHandler(v.escapeMenu); err != nil { // TODO: hack
// https://github.com/OpenDiablo2/OpenDiablo2/issues/792
if err := v.inputManager.UnbindHandler(v.escapeMenu); err != nil {
return err
}
@ -225,7 +227,7 @@ func (v *Game) Advance(elapsed float64) error {
v.soundEngine.Advance(elapsed)
if (v.escapeMenu != nil && !v.escapeMenu.IsOpen()) || len(v.gameClient.Players) != 1 {
v.gameClient.MapEngine.Advance(elapsed) // TODO: Hack
v.gameClient.MapEngine.Advance(elapsed)
}
if v.gameControls != nil {
@ -247,7 +249,6 @@ func (v *Game) Advance(elapsed float64) error {
// skip showing zone change text the first time we enter the world
if v.lastRegionType != d2enum.RegionNone && v.lastRegionType != tile.RegionType {
//TODO: Should not be using RegionType as an index - this will return incorrect LevelDetails record for most of the zones.
areaName := levelDetails.LevelDisplayName
areaChgStr := fmt.Sprintf("Entering The %s", areaName)
v.gameControls.SetZoneChangeText(areaChgStr)

View File

@ -105,13 +105,12 @@ type MapEngineTest struct {
selX, selY int
selectedTile *d2mapengine.MapTile
//TODO: this is region specific properties, should be refactored for multi-region rendering
// https://github.com/OpenDiablo2/OpenDiablo2/issues/806
currentRegion int
levelPreset int
fileIndex int
regionSpec regionSpec
filesCount int
debugVisLevel int
}
// CreateMapEngineTest creates the Map Engine Test screen and returns a pointer to it
@ -223,6 +222,7 @@ func (met *MapEngineTest) OnLoad(loading d2screen.LoadingState) {
// OnUnload releases the resources for the Map Engine Test screen
func (met *MapEngineTest) OnUnload() error {
// https://github.com/OpenDiablo2/OpenDiablo2/issues/792
if err := met.inputManager.UnbindHandler(met); err != nil {
return err
}
@ -302,6 +302,7 @@ func (met *MapEngineTest) Render(screen d2interface.Surface) error {
screen.PushTranslation(lineBigIndentX, 0)
defer screen.Pop()
screen.DrawTextf("Floors")
tpop = 0
@ -322,6 +323,7 @@ func (met *MapEngineTest) Render(screen d2interface.Surface) error {
screen.PushTranslation(lineBigIndentX, 0)
defer screen.Pop()
screen.DrawTextf("Shadows")
tpop = 0
@ -342,6 +344,7 @@ func (met *MapEngineTest) Render(screen d2interface.Surface) error {
screen.PushTranslation(lineBigIndentX, 0)
defer screen.Pop()
screen.DrawTextf("Substitutions")
tpop = 0

View File

@ -12,8 +12,6 @@ import (
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2gui"
)
// TODO: fix pentagram
type (
layoutID int
optionID int

View File

@ -233,7 +233,7 @@ const (
type GameControls struct {
actionableRegions []actionableRegion
asset *d2asset.AssetManager
renderer d2interface.Renderer // TODO: This shouldn't be a dependency
renderer d2interface.Renderer // https://github.com/OpenDiablo2/OpenDiablo2/issues/798
inputListener inputCallbackListener
hero *d2mapentity.Player
heroState *d2hero.HeroStateFactory
@ -251,7 +251,6 @@ type GameControls struct {
rightMenuRect *d2geom.Rectangle
lastMouseX int
lastMouseY int
missileID int
globeSprite *d2ui.Sprite
hpManaStatusSprite *d2ui.Sprite
mainPanel *d2ui.Sprite
@ -314,7 +313,6 @@ func NewGameControls(
hpManaStatsLabel := ui.NewLabel(d2resource.Font16, d2resource.PaletteUnits)
hpManaStatsLabel.Alignment = d2gui.HorizontalAlignLeft
// TODO make this depend on the hero type to respect inventory.txt
var inventoryRecordKey string
switch hero.Class {
@ -794,7 +792,7 @@ func (g *GameControls) Load() {
log.Print(err)
}
// TODO: temporarily hardcoded to Attack, should come from saved state for hero
// https://github.com/OpenDiablo2/OpenDiablo2/issues/799
genericSkillsSprite, err := g.ui.NewSprite(d2resource.GenericSkills, d2resource.PaletteSky)
if err != nil {
log.Print(err)
@ -837,7 +835,8 @@ func (g *GameControls) loadUIButtons() {
func (g *GameControls) onToggleRunButton() {
g.runButton.Toggle()
g.hero.ToggleRunWalk()
// TODO: change the running menu icon
// https://github.com/OpenDiablo2/OpenDiablo2/issues/800
g.hero.SetIsRunning(g.hero.IsRunToggled())
}
@ -862,7 +861,7 @@ func (g *GameControls) updateLayout() {
}
func (g *GameControls) isLeftPanelOpen() bool {
// TODO: add quest log panel
// https://github.com/OpenDiablo2/OpenDiablo2/issues/801
return g.heroStatsPanel.IsOpen()
}
@ -903,7 +902,6 @@ func (g *GameControls) isInActiveMenusRect(px, py int) bool {
}
// Render draws the GameControls onto the target
// TODO: consider caching the panels to single image that is reused.
func (g *GameControls) Render(target d2interface.Surface) error {
g.renderForSelectableEntitiesHovered(target)

View File

@ -147,8 +147,6 @@ type Overlay struct {
text []*d2ui.Label
lines []line
uiManager *d2ui.UIManager
originX int
originY int
layout *d2gui.Layout
closeButton *d2ui.Button
guiManager *d2gui.GuiManager
@ -207,7 +205,6 @@ func (h *Overlay) IsOpen() bool {
// IsInRect checks if the given point is within the overlay layout rectangle
func (h *Overlay) IsInRect(px, py int) bool {
ww, hh := h.layout.GetSize()
x, y := h.layout.GetPosition()
@ -323,18 +320,20 @@ func (h *Overlay) Load() {
h.text = append(h.text, newLabel)
// Bullets
// the hotkeys displayed here should be pulled from a mapping of input events to game events
// https://github.com/OpenDiablo2/OpenDiablo2/issues/793
// https://github.com/OpenDiablo2/OpenDiablo2/issues/794
callouts := []struct{ text string }{
// TODO "Ctrl" should be hotkey // "Hold Down <%s> to Run"
// "Ctrl" should be hotkey // "Hold Down <%s> to Run"
{text: fmt.Sprintf(d2tbl.TranslateString("StrHelp2"), "Ctrl")},
// TODO "Alt" should be hotkey // "Hold down <%s> to highlight items on the ground"
// "Alt" should be hotkey // "Hold down <%s> to highlight items on the ground"
{text: fmt.Sprintf(d2tbl.TranslateString("StrHelp3"), "Alt")},
// TODO "Shift" should be hotkey // "Hold down <%s> to attack while standing still"
// "Shift" should be hotkey // "Hold down <%s> to attack while standing still"
{text: fmt.Sprintf(d2tbl.TranslateString("StrHelp4"), "Shift")},
// TODO "Tab" should be hotkey // "Hit <%s> to toggle the automap on and off"
// "Tab" should be hotkey // "Hit <%s> to toggle the automap on and off"
{text: fmt.Sprintf(d2tbl.TranslateString("StrHelp5"), "Tab")},
// "Hit <Esc> to bring up the Game Menu"
@ -346,7 +345,7 @@ func (h *Overlay) Load() {
// "Hit F1-F8 to set your Left or Right Mouse Buttton Skills."
{text: d2tbl.TranslateString("StrHelp8")},
// TODO "H" should be hotkey,
// "H" should be hotkey,
{text: fmt.Sprintf(d2tbl.TranslateString("StrHelp8a"), "H")},
}

View File

@ -51,7 +51,8 @@ func NewInventory(asset *d2asset.AssetManager, ui *d2ui.UIManager,
hoverLabel := ui.NewLabel(d2resource.FontFormal11, d2resource.PaletteStatic)
hoverLabel.Alignment = d2gui.HorizontalAlignCenter
itemFactory, _ := diablo2item.NewItemFactory(asset) // TODO handle errors
// https://github.com/OpenDiablo2/OpenDiablo2/issues/797
itemFactory, _ := diablo2item.NewItemFactory(asset)
return &Inventory{
asset: asset,
@ -91,7 +92,7 @@ func (g *Inventory) Load() {
g.panel, _ = g.uiManager.NewSprite(d2resource.InventoryCharacterPanel, d2resource.PaletteSky)
// TODO: remove this item test code
// https://github.com/OpenDiablo2/OpenDiablo2/issues/795
testInventoryCodes := [][]string{
{"kit", "Crimson", "of the Bat", "of Frost"},
{"rin", "Steel", "of Shock"},
@ -111,6 +112,7 @@ func (g *Inventory) Load() {
inventoryItems = append(inventoryItems, item)
}
// https://github.com/OpenDiablo2/OpenDiablo2/issues/795
testEquippedItemCodes := map[d2enum.EquippedSlot][]string{
d2enum.EquippedSlotLeftArm: {"wnd"},
d2enum.EquippedSlotRightArm: {"buc"},
@ -133,7 +135,6 @@ func (g *Inventory) Load() {
g.grid.ChangeEquippedSlot(slot, item)
}
// TODO: Load the player's actual items
_, err := g.grid.Add(inventoryItems...)
if err != nil {
fmt.Printf("could not add items to the inventory, err: %v\n", err)

View File

@ -21,6 +21,10 @@ import (
// for each row in inventory, we need to account for this padding
const cellPadding = 1
const (
fmtFlippyFile = "/data/global/items/inv%s.dc6"
)
// InventoryItem is an interface for an items that can be placed in the inventory grid
type InventoryItem interface {
InventoryGridSize() (width int, height int)
@ -127,8 +131,7 @@ func (g *ItemGrid) loadItem(item InventoryItem) {
if _, exists := g.sprites[item.GetItemCode()]; !exists {
var itemSprite *d2ui.Sprite
// TODO: Put the pattern into D2Shared
imgPath := fmt.Sprintf("/data/global/items/inv%s.dc6", item.GetItemCode())
imgPath := fmt.Sprintf(fmtFlippyFile, item.GetItemCode())
itemSprite, err := g.uiManager.NewSprite(imgPath, d2resource.PaletteSky)
if err != nil {

View File

@ -88,7 +88,6 @@ func (s *SkillPanel) Close() {
// IsInRect returns whether the X Y coordinates are in some of the list rows of the panel.
func (s *SkillPanel) IsInRect(x, y int) bool {
for _, listRow := range s.ListRows {
// TODO: investigate why listRow can be nil
if listRow != nil && listRow.IsInRect(x, y) {
return true
}

View File

@ -51,7 +51,7 @@ func Create(connectionType d2clientconnectiontype.ClientConnectionType,
asset *d2asset.AssetManager, scriptEngine *d2script.ScriptEngine) (*GameClient, error) {
result := &GameClient{
asset: asset,
MapEngine: d2mapengine.CreateMapEngine(asset), // TODO: Mapgen - Needs levels.txt stuff
MapEngine: d2mapengine.CreateMapEngine(asset),
Players: make(map[string]*d2mapentity.Player),
connectionType: connectionType,
scriptEngine: scriptEngine,
@ -152,7 +152,7 @@ func (g *GameClient) OnPacketReceived(packet d2netpacket.NetPacket) error {
// Not implemented
log.Printf("RemoteClientConnection: received disconnect: %s", packet.PacketData)
case d2netpackettype.ServerClosed:
// TODO: Need to be tied into a character save and exit
// https://github.com/OpenDiablo2/OpenDiablo2/issues/802
log.Print("Server has been closed")
os.Exit(0)
default:
@ -321,7 +321,7 @@ func (g *GameClient) createSummonedNpcEntity(skillRecord *d2records.SkillRecord,
return nil, fmt.Errorf("Cannot cast skill - No monstat entry for \"%s\"", skillRecord.Summon)
}
// TODO: overlay animations for the summon
// https://github.com/OpenDiablo2/OpenDiablo2/issues/803
summonedNpcEntity, err := g.MapEngine.NewNPC(X, Y, monsterStatsRecord, 0)
if err != nil {
return nil, err
@ -342,7 +342,7 @@ func (g *GameClient) createMissileEntities(skillRecord *d2records.SkillRecord, p
missileEntities := make([]*d2mapentity.Missile, 0)
for _, missileRecord := range missileRecords {
if missileRecord == nil {
continue;
continue
}
missileEntity, err := g.createMissileEntity(missileRecord, player, castX, castY)
@ -356,7 +356,7 @@ func (g *GameClient) createMissileEntities(skillRecord *d2records.SkillRecord, p
return missileEntities, nil
}
func (g *GameClient) createMissileEntity(missileRecord *d2records.MissileRecord, player *d2mapentity.Player, castX, castY float64) (*d2mapentity.Missile, error){
func (g *GameClient) createMissileEntity(missileRecord *d2records.MissileRecord, player *d2mapentity.Player, castX, castY float64) (*d2mapentity.Missile, error) {
if missileRecord == nil {
return nil, nil
}

View File

@ -86,7 +86,7 @@ func NewGameServer(asset *d2asset.AssetManager, networkServer bool,
// load files independent of the app.
mapEngine := d2mapengine.CreateMapEngine(asset)
mapEngine.SetSeed(gameServer.seed)
mapEngine.ResetMap(d2enum.RegionAct1Town, 100, 100) // TODO: Mapgen - Needs levels.txt stuff
mapEngine.ResetMap(d2enum.RegionAct1Town, 100, 100)
mapGen, err := d2mapgen.NewMapGenerator(asset, mapEngine)
if err != nil {