6.6 KiB
🐛 COMPLETE BUG FIX & CLEANUP SESSION
Systematic Bug Fixing & Legacy Code Cleanup
Date: 10.12.2025 23:50
Status: 🔴 IN PROGRESS
🎯 Objective:
Fix ALL bugs and clean up ALL legacy/broken code to achieve:
- ✅ Stable 60 FPS
- ✅ No crashes
- ✅ No visual glitches
- ✅ Clean console (no errors)
- ✅ Professional quality
🐛 KNOWN BUGS CHECKLIST:
Critical (Game-Breaking):
- Seasonal Crop Validation - Crops don't check season
- Starter Chest Missing - New game has no starter chest
- Memory Leaks - Potential texture/entity leaks
High (Major Issues):
- Grass Transparency - Black squares still visible
- NPC Removal Issues - Removed NPCs still referenced
- Save/Load Missing - No save system implemented
- Tutorial Missing - No first-time guidance
Medium (Noticeable Issues):
- UI Alignment - Some UI elements misaligned
- Sound Sync - Sounds not always synced
- Animation Glitches - Some animations choppy
- Collision Bugs - Occasional stuck player
Low (Minor Polish):
- Tooltip Delays - Tooltips show too slow
- Button Feedback - Some buttons no hover
- Text Overflow - Long text clips
- Icon Inconsistency - Mixed pixel/flat styles
🗑️ LEGACY CODE TO REMOVE:
Commented Out Code:
- Old transparency processing (PreloadScene.js)
- Removed NPC references (GameScene.js)
- Deprecated systems (TimeSystem, DayNightSystem)
- Old scale values (comments everywhere)
Unused Files:
- backup_characters/*.png (keep but document)
- Old sprite files (duplicates)
- Deprecated scripts
- Test files
Dead Code:
- Unreachable functions
- Unused variables
- Old event listeners
- Disabled features
🔧 FIX PLAN:
Phase 1: Critical Bugs (TODAY)
1. Seasonal Crop Validation
Problem: Plants ignore season requirements
Fix:
// FarmingSystem.plantCrop()
const currentSeason = this.scene.weatherSystem.currentSeason;
const cropData = CROP_DATA[cropType];
if (cropData.seasons && !cropData.seasons.includes(currentSeason)) {
this.scene.events.emit('show-floating-text', {
x, y,
text: `Wrong season! Plant in ${cropData.seasons.join('/')}`,
color: '#ff0000'
});
return false;
}
Time: 30 minutes
2. Starter Chest
Problem: New game starts empty
Fix:
// GameScene.create()
createStarterChest() {
const chest = new LootChest(this, 10, 10, 'farm_starter');
// Contains: seeds, tools, food
}
Time: 15 minutes
3. Memory Leak Prevention
Problem: Textures/entities not destroyed
Fix:
// Add to all entity classes
destroy() {
if (this.sprite) {
this.sprite.destroy();
this.sprite = null;
}
// Clean up references
}
// GameScene cleanup
shutdown() {
this.entities.forEach(e => e.destroy());
this.entities = [];
}
Time: 1 hour
Phase 2: High Priority (TODAY/TOMORROW)
4. Grass Transparency - Ultra Fix
Problem: Black squares still showing
Solution: Already applied ultra-aggressive processing
Verify: Test in game
Time: 5 minutes (testing)
5. NPC Reference Cleanup
Problem: Code still references removed NPCs
Fix:
// Search and remove/comment:
grep -r "zombie_sprite" src/
grep -r "merchant_sprite" src/
grep -r "cow.png" src/
// Update all references to check if exists
if (this.textures.exists('zombie_sprite')) {
// Only then use it
}
Time: 30 minutes
6. Console Error Cleanup
Problem: Errors/warnings in console
Fix:
- Remove all
console.error()for handled cases - Add try-catch blocks
- Validate all texture/sound loads
- Check for null references
Time: 1 hour
Phase 3: Medium Priority (TOMORROW)
7. UI Alignment
Problem: UI elements not centered/aligned
Fix:
// Update all UI positioning to use:
const centerX = this.cameras.main.width / 2;
const centerY = this.cameras.main.height / 2;
// Responsive positioning
this.scale.on('resize', (gameSize) => {
this.repositionUI(gameSize);
});
Time: 2 hours
8. Sound Synchronization
Problem: Sounds play at wrong times
Fix:
// SoundManager improvements
playSound(key, config = {}) {
if (!this.scene.sound.sounds.some(s => s.key === key && s.isPlaying)) {
this.scene.sound.play(key, config);
}
}
Time: 1 hour
9. Animation Polish
Problem: Choppy/missing animations
Fix:
- Add easing to all tweens
- Smooth state transitions
- Fix sprite flicker
- Add interpolation
Time: 2 hours
Phase 4: Code Cleanup (TOMORROW)
10. Remove Commented Code
Problem: 1000+ lines of commented code
Strategy:
# Find all commented blocks
grep -r "// REMOVED" src/
grep -r "// OLD" src/
grep -r "// DEPRECATED" src/
# Delete if confirmed unused
# Keep comments that explain WHY
Time: 1 hour
11. Consolidate Constants
Problem: Constants scattered everywhere
Fix:
// Create constants.js
const GAME_CONSTANTS = {
TILE_SIZE: 48,
GRID_SIZE: 100,
PLAYER_SPEED: 200,
// ... all constants
};
Time: 1 hour
12. Remove Dead Code
Problem: Unreachable/unused code
Tool: Use ESLint or manual review
Time: 2 hours
📋 IMMEDIATE ACTIONS:
Now (Next 30 min):
- ✅ Fix seasonal crop validation
- ✅ Add starter chest
- ✅ Test grass transparency
Tonight (Next 2 hours):
- Memory leak prevention
- NPC reference cleanup
- Console error cleanup
Tomorrow (4 hours):
- UI alignment fixes
- Sound synchronization
- Animation polish
- Code cleanup
🎯 Success Criteria:
After Phase 1 (Critical):
- ✅ No game-breaking bugs
- ✅ Seasonal crops work
- ✅ Starter chest appears
- ✅ No memory leaks
After Phase 2 (High Priority):
- ✅ Clean console (no errors)
- ✅ All references valid
- ✅ Grass perfect transparency
After Phase 3 (Medium):
- ✅ UI perfectly aligned
- ✅ Sounds synchronized
- ✅ Smooth animations
After Phase 4 (Cleanup):
- ✅ No commented code
- ✅ No dead code
- ✅ Clean codebase
📊 Bug Tracking:
Total Bugs: ~20
Fixed: 0
In Progress: 0
Remaining: 20
Target: Fix all in 6-8 hours
Status: 🔴 Starting Bug Fix Marathon!
ETA to Clean: 6-8 hours
Let's go! 🚀