Skip to content

Commit 28508d7

Browse files
committed
log log
1 parent b6f3e56 commit 28508d7

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,7 @@ deploy:
3333
fly deploy
3434

3535
fly-db-connect:
36-
fly mpg connect $(PG_CLUSTER_ID)
36+
fly mpg connect $(PG_CLUSTER_ID)
37+
38+
fly-logs:
39+
fly logs --app timehelm

client/src/game-client.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,15 @@ export class GameClient {
271271
* @param entities - Array of all entity data
272272
*/
273273
private handleWorldState(players: PlayerData[], entities: EntityData[]): void {
274+
// Debug: Log entity information
275+
if (entities.length > 0) {
276+
console.log(`[WorldState] Received ${entities.length} entities:`, entities.map(e => ({
277+
id: e.id,
278+
type: e.entity_type,
279+
position: e.position
280+
})));
281+
}
282+
274283
// Update players
275284
for (const playerData of players) {
276285
if (playerData.id !== this.user.id) {
@@ -293,6 +302,7 @@ export class GameClient {
293302
existingEntity.position = entityData.position;
294303
existingEntity.rotation = entityData.rotation;
295304
} else {
305+
console.log(`[WorldState] Adding new entity: ${entityData.id} (${entityData.entity_type}) at`, entityData.position);
296306
this.addEntity(entityData);
297307
}
298308
}
@@ -396,8 +406,13 @@ export class GameClient {
396406

397407
private addEntity(entityData: EntityData): void {
398408
const entity = Entity.fromData(entityData);
399-
this.scene?.add(entity.mesh);
400-
this.entities.set(entityData.id, entity);
409+
if (this.scene) {
410+
this.scene.add(entity.mesh);
411+
this.entities.set(entityData.id, entity);
412+
console.log(`[Entity] Added entity ${entityData.id} to scene. Mesh position:`, entity.mesh.position, 'Entity count:', this.entities.size);
413+
} else {
414+
console.error('[Entity] Cannot add entity - scene is null!');
415+
}
401416
}
402417

403418
private removeEntity(entityId: string): void {

server/src/game.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ impl GameState {
172172
},
173173
);
174174

175+
let entity_count = entities.len();
176+
tracing::info!("GameState initialized with {} entities", entity_count);
175177
Self {
176178
players: HashMap::new(),
177179
entities,

server/src/main.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,16 @@ async fn main() -> anyhow::Result<()> {
149149

150150
let world_state = GameMessage::WorldState {
151151
players: all_players,
152-
entities: all_entities,
152+
entities: all_entities.clone(),
153153
};
154154
// Serialize and broadcast to all WebSocket clients
155155
if let Ok(world_json) = serde_json::to_string(&world_state) {
156156
let _ = broadcast_tx_for_task.send(world_json);
157+
} else {
158+
tracing::warn!("Failed to serialize world state");
159+
}
160+
if !all_entities.is_empty() {
161+
tracing::debug!("Broadcasting {} entities", all_entities.len());
157162
}
158163
}
159164
});

0 commit comments

Comments
 (0)