Skip to content

Commit

Permalink
Merge pull request #462 from akashic-games/drop-former-storage
Browse files Browse the repository at this point in the history
refactor: drop the former storage implementation
  • Loading branch information
yu-ogi authored Sep 7, 2023
2 parents 1b8eb50 + 24c566a commit b5236cd
Show file tree
Hide file tree
Showing 15 changed files with 42 additions and 1,462 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# ChangeLog

## 3.15.0
* `g.Storage` とその周辺のコードを削除
* ゲーム開発者に影響はありません。

### エンジン開発者への影響
* `g.Game#storage` が削除されます。
* `g.JoinEvent` のコンストラクタ関数の引数が一部変更になります。

## 3.14.2
* `g.Scene#seethrough` を追加

Expand Down
1 change: 0 additions & 1 deletion doc/misc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
* [game.jsonの仕様](game-json.html)
* [素材の推奨仕様](asset-recommended-spec.html)
* [CompositeOperationの利用について](composite-operation.html)
* [ストレージについて](storage.html)
* [アセットロードエラーについて](asset-load-error.html)
* [akashic init テンプレート利用ガイド](template-guide.html)
249 changes: 0 additions & 249 deletions doc/misc/storage.md

This file was deleted.

8 changes: 4 additions & 4 deletions src/Event.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { CommonOffset } from "@akashic/pdi-types";
import type { Player } from "./Player";
import type { RandomGenerator } from "./RandomGenerator";
import type { StorageValueStore } from "./Storage";

/**
* イベントの種別。
Expand Down Expand Up @@ -230,13 +229,14 @@ export class JoinEvent implements Event {
type: "join" = "join";
eventFlags: number;
player: Player;
storageValues: StorageValueStore | undefined;

constructor(player: Player, storageValues?: StorageValueStore, eventFlags?: number) {
// NOTE: 型の後方互換のために念のためプロパティのみ残しておく
storageValues: unknown;

constructor(player: Player, eventFlags?: number) {
// @ts-ignore TODO: eventFlags のデフォルト値の扱い
this.eventFlags = eventFlags;
this.player = player;
this.storageValues = storageValues;
}
}

Expand Down
13 changes: 1 addition & 12 deletions src/EventConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { EventIndex } from "./EventIndex";
import { ExceptionFactory } from "./ExceptionFactory";
import type { InternalOperationPluginOperation } from "./OperationPluginOperation";
import type { Player } from "./Player";
import { StorageValueStore } from "./Storage";
import type { WeakRefKVS } from "./WeakRefKVS";

/**
Expand Down Expand Up @@ -76,17 +75,7 @@ export class EventConverter {
// @ts-ignore
this._playerTable[playerId] = player;

let store: StorageValueStore | undefined = undefined;
if (pev[EventIndex.Join.StorageData]) {
const keys: pl.StorageReadKey[] = [];
const values: pl.StorageValue[][] = [];
pev[EventIndex.Join.StorageData].map((data: pl.StorageData) => {
keys.push(data.readKey);
values.push(data.values);
});
store = new StorageValueStore(keys, values);
}
return new JoinEvent(player, store, prio);
return new JoinEvent(player, prio);

case pl.EventCode.Leave:
delete this._playerTable[player.id];
Expand Down
4 changes: 2 additions & 2 deletions src/EventIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export module EventIndex {
export const enum Tick {
Age = 0,
Events = 1,
StorageData = 2
StorageData = 2 // TODO: 削除
}

export const enum TickList {
Expand All @@ -33,7 +33,7 @@ export module EventIndex {
EventFlags = 1,
PlayerId = 2,
PlayerName = 3,
StorageData = 4,
StorageData = 4, // TODO: 削除
Local = 5
}

Expand Down
14 changes: 2 additions & 12 deletions src/Game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import { PointEventResolver } from "./PointEventResolver";
import type { RandomGenerator } from "./RandomGenerator";
import { Scene } from "./Scene";
import type { SnapshotSaveRequest } from "./SnapshotSaveRequest";
import { Storage } from "./Storage";
import { SurfaceAtlasSet } from "./SurfaceAtlasSet";
import type { TickGenerationModeString } from "./TickGenerationModeString";
import { WeakRefKVS } from "./WeakRefKVS";
Expand Down Expand Up @@ -457,11 +456,6 @@ export class Game {
*/
handlerSet: GameHandlerSet;

/**
* ストレージ。
*/
storage: Storage;

/**
* ゲーム開発者向けのコンテナ。
*
Expand Down Expand Up @@ -870,7 +864,7 @@ export class Game {
throw ExceptionFactory.createAssertionError("Game#skippingScene: only 'full-local' scene is supported.");
}
if (scene._needsLoading()) {
throw ExceptionFactory.createAssertionError("Game#skippingScene: must not depend on any assets/storages.");
throw ExceptionFactory.createAssertionError("Game#skippingScene: must not depend on any assets.");
}
}
this._skippingScene = scene;
Expand Down Expand Up @@ -916,7 +910,6 @@ export class Game {
this.audio = new AudioSystemManager(this.resourceFactory);

this.defaultAudioSystemId = "sound";
this.storage = new Storage();
this.assets = {};
this.surfaceAtlasSet = new SurfaceAtlasSet({ resourceFactory: this.resourceFactory });

Expand Down Expand Up @@ -1712,7 +1705,6 @@ export class Game {

// TODO より能動的にdestroy処理を入れるべきかもしれない
this.resourceFactory = undefined!;
this.storage = undefined!;

this.playId = undefined;
this.operationPlugins = undefined!; // this._operationPluginManager.pluginsのエイリアスなので、特に破棄処理はしない。
Expand Down Expand Up @@ -2043,9 +2035,7 @@ export class Game {

if (scene._needsLoading() && scene._loadingState !== "loaded-fired") {
if (this._defaultLoadingScene._needsLoading())
throw ExceptionFactory.createAssertionError(
"Game#_doPushScene: _defaultLoadingScene must not depend on any assets/storages."
);
throw ExceptionFactory.createAssertionError("Game#_doPushScene: _defaultLoadingScene must not depend on any assets.");
this._doPushScene(loadingScene, true, this._defaultLoadingScene);
loadingScene.reset(scene);
} else {
Expand Down
Loading

0 comments on commit b5236cd

Please sign in to comment.