98 lines
4.1 KiB
Markdown
98 lines
4.1 KiB
Markdown
# Building Handler Documentation
|
|||
|
|
|
||
|
|
## Overview
|
||
|
|
This document describes the database relationships and interactions for the `dbBuildingHandler` class. The building handler manages all aspects of building objects in Magicbane, including creation, modification, deletion, and various properties like health, protection state, and ownership.
|
||
|
|
|
||
|
|
## Handler Class
|
||
|
|
**File:** `src/engine/db/handlers/dbBuildingHandler.java`
|
||
|
|
**Class:** `dbBuildingHandler`
|
||
|
|
**Extends:** `dbHandlerBase`
|
||
|
|
|
||
|
|
## Database Tables
|
||
|
|
|
||
|
|
### Main Building Table
|
||
|
|
- **Table Name:** `obj_building`
|
||
|
|
- **Description:** Core building information including location, mesh, health, and ownership details
|
||
|
|
- **Columns:**
|
||
|
|
- UID (Primary Key)
|
||
|
|
- parent (Foreign Key to obj_zone)
|
||
|
|
- ownerUUID (Foreign Key to obj_character)
|
||
|
|
- name
|
||
|
|
- meshUUID (Foreign Key to static_building_mesh)
|
||
|
|
- locX, locY, locZ (Location coordinates)
|
||
|
|
- meshScale
|
||
|
|
- currentHP
|
||
|
|
- protectionState
|
||
|
|
- currentGold
|
||
|
|
- rank
|
||
|
|
- upgradeDate
|
||
|
|
- blueprintUUID (Foreign Key to static_building_blueprint)
|
||
|
|
- w, rotY (Rotation data)
|
||
|
|
- isDeleted
|
||
|
|
|
||
|
|
### Related Tables
|
||
|
|
|
||
|
|
| Table Name | Description | Relationship |
|
||
|
|
|------------|-------------|--------------|
|
||
|
|
| `dyn_building_friendslist` | Stores friends that can access this building | BuildingID → obj_building.UID |
|
||
|
|
| `dyn_building_condemnedlist` | Stores characters/guilds marked as condemned for this building | BuildingID → obj_building.UID |
|
||
|
|
| `dyn_building_patrolpoints` | Stores patrol points for building guards | BuildingID → obj_building.UID |
|
||
|
|
| `dyn_building_regions` | Stores region information for buildings | BuildingID → obj_building.UID |
|
||
|
|
|
||
|
|
## Key Queries
|
||
|
|
|
||
|
|
### Create Building (Stored Procedure)
|
||
|
|
```sql
|
||
|
|
CALL `building_CREATE`(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||
|
|
```
|
||
|
|
**File:** `dbBuildingHandler.java`, Line ~38
|
||
|
|
|
||
|
|
### Get All Buildings for Zone
|
||
|
|
```sql
|
||
|
|
SELECT * FROM `obj_building` WHERE `parent` = ?
|
||
|
|
```
|
||
|
|
**File:** `dbBuildingHandler.java`, Line ~91
|
||
|
|
|
||
|
|
### Get Building by UUID
|
||
|
|
```sql
|
||
|
|
SELECT * FROM `obj_building` WHERE `UID` = ?
|
||
|
|
```
|
||
|
|
**File:** `dbBuildingHandler.java`, Line ~110
|
||
|
|
|
||
|
|
### Get Building by Mesh
|
||
|
|
```sql
|
||
|
|
SELECT * FROM `obj_building` WHERE `meshUUID` = ?
|
||
|
|
```
|
||
|
|
**File:** `dbBuildingHandler.java`, Line ~135
|
||
|
|
|
||
|
|
## Relationships
|
||
|
|
|
||
|
|
1. **Building to Zone:** Many-to-one relationship through `obj_building.parent` field
|
||
|
|
2. **Building to Owner:** Many-to-one relationship through `obj_building.ownerUUID` field (references obj_character.UID)
|
||
|
|
3. **Building to Blueprint:** Many-to-one relationship through `obj_building.blueprintUUID` field (references static_building_blueprint.Rank0UUID)
|
||
|
|
4. **Building to Mesh:** Many-to-one relationship through `obj_building.meshUUID` field (references static_building_mesh.UID)
|
||
|
|
5. **Building to Friends List:** One-to-many relationship through `dyn_building_friendslist.BuildingID`
|
||
|
|
6. **Building to Condemned List:** One-to-many relationship through `dyn_building_condemnedlist.BuildingID`
|
||
|
|
7. **Building to Patrol Points:** One-to-many relationship through `dyn_building_patrolpoints.BuildingID`
|
||
|
|
8. **Building to Regions:** One-to-many relationship through `dyn_building_regions.BuildingID`
|
||
|
|
|
||
|
|
## Java Field to Database Column Mappings
|
||
|
|
|
||
|
|
| Java Field | Database Column | Notes |
|
||
|
|
|------------|-----------------|-------|
|
||
|
|
| `parent` | `obj_building.parent` | Zone parent ID |
|
||
|
|
| `ownerUUID` | `obj_building.ownerUUID` | Owner character UID |
|
||
|
|
| `name` | `obj_building.name` | Building name |
|
||
|
|
| `meshUUID` | `obj_building.meshUUID` | Mesh identifier |
|
||
|
|
| `locX` | `obj_building.locX` | X coordinate |
|
||
|
|
| `locY` | `obj_building.locY` | Y coordinate |
|
||
|
|
| `locZ` | `obj_building.locZ` | Z coordinate |
|
||
|
|
| `meshScale` | `obj_building.meshScale` | Scale of mesh |
|
||
|
|
| `currentHP` | `obj_building.currentHP` | Current health points |
|
||
|
|
| `protectionState` | `obj_building.protectionState` | Protection state |
|
||
|
|
| `currentGold` | `obj_building.currentGold` | Current gold amount |
|
||
|
|
| `rank` | `obj_building.rank` | Building rank |
|
||
|
|
| `upgradeDate` | `obj_building.upgradeDate` | Upgrade timestamp |
|
||
|
|
| `blueprintUUID` | `obj_building.blueprintUUID` | Blueprint identifier |
|
||
|
|
| `w` | `obj_building.w` | Rotation data |
|
||
|
|
| `rotY` | `obj_building.rotY` | Y rotation angle |
|