This area is waste of space as long as you haven't logged in... Do so, or register if you don't have an account yet.
Developer's documentation
Files
Root
acorn.php - Magic-revival requesting. 'nuf said.attack.php - Attack-validity-check. Runs
weapon_($target_uID) if everything is fine. weapon_<weaponname>_instamiss($target_uID) if seems that the attacker is cheating (shares same IP with target). Weapon-functions are loaded from tech/weapon_<weaponname>.phpforum.php - Everything forum-related, except functions.
guild-owner.php - Owner-panel for guilds.
guild.php - Everything guild-related that is meant for everyone. Handles also Guild-PMs.
index.php - Mainpage for unregistered, "home" for registered people.
inventory.php - Shows inventory, for registered.
login.php - Shows nothing, logs player in and redirects to index.php if provided login is ok.
logout.php - Logs player out. Duh
move.php - Moving and map-drawing. inc/footer.php includes this always.
pm.php - Show/Send PMs.
profile.php - Show/Edit profiles/accounts. Note: Admins' profile-editing stuff is in pwn-ui/user.php
register.php - Registeration-stuff.
revive.php - Revivification. Note: Moving player to hospital is done in
remove_hp($target_uid, $hp=1, $hitby)-function.search.php - Handles item-searching/finding.
cr0n/
Note: I recommend renaming this directory in live games. No file outside this directory refers here, so it's perfectly safe. Only thing you have to change is cron-jobs.daily.php - Stuff intended to be run once-a-day. Changes locations' "ownerstuff" and delivers acorns to hospitals.
halfhour.php - Stuff that is ran every 30 minutes. Changes locations-with-highrep-players' "ownerstuff".
fivemin.php - Stuff that is ran every 5 minutes.
inc/
db.php - Database-setup and connection.footer.php - Shows sidebar, map and footer. Closes DB-connection.
functions.php - Every game's own function is defined here.
header.php - Connects to database by calling db.php and shows location-info.
navbar.php - Navigation-bar, duh.
sidebar.php - Draws sidebar. Shown sidebar is determined by current page's filename.
side_showinfo() is shown always, side_general() is shown if no matching sidebar-function (side_() is found.pwn-ui
Remember to set$admin = '../' before including ../inc/header.php!
guild.php - Guild-manager.index.php - Admin-panel's main menu. mapedit.php - Map-editor.
news.php - News-manager.
tech-manager.php -
user.php - User-manager.
tech/
Weapons
Every weapon-file must haveweapon_-prefix, otherwise it's not detected as one. Must include functions weapon_weaponname($target_uid) (called if attack is valid) and weapon_weaponname_instamiss($target_uid) (called if attacker seems to cheat, i.e shares same IP with target).
Items
Items... No required functions yet. Files must be named withitem_-prefix, anyway.
ui/
Extra-stuff for user-interface, i.e CSS and images belongs here.style.css - Stylesheet. Duh.
Fuctions
Security
GenMD5($string) - Generate salted MD5-hash. Mainly for passwords.GenCode($string) - Generate (pseudo?)random hash for identification-stuff (login-hash?).
DBEscape($untrusted_string) - Make strings MySQL-safe. ALWAYS ESCAPE USER-INPUT IF IT IS GOING TO BE USED IN SQL-QUERIES.
migrate_test($username, $password) - Check if the user used to play HCSv1.
Forum
is_locked($post, $query = FALSE) - Test if a post/thread is locked. $query is boolean. If it's false (default), no DB-query is needed and the lock-bit is checked from the provided $post, that is considered as array. If $query is true, we'll fetch checkable topic's ID from $post. If $post is array, the ID will be fetched from $post['tid']. If it's not, $post is used as Topic ID.get_subject($topic_id) - Return the subject of topic with ID $topic_id.
Formatting
BBdeCode($bbencoded) - Convert BBCodes to HTML from a string. And line-breaks to HTML-line-breakspro_filter($text) - Profanity-filter. Converts also \' to ' (in theory it's not needed because of the way
DBEscape($untrusted_string) works). MUST NOT BE USED FOR ANYTHING THAT IS GOING TO DATABASE.Others
show_news() - Show 5 recentest news.nearest_hospital($x, $y, $race) - Fetch nearest hospital from $x and $y. $race is user's race. Returns nearest hospital's info-array.
get_map($user_id) - Update global $map-array according to $user_id's current location.
remove_ap($user_id, $ap = 1) - Remove APs as much as $ap says from the player who owns $user_id.
remove_magic($user_id, $magic = 1) - See above. For magic
remove_hp($user_id, $hp = 1, $hitby=0) - See above. For HP. Also moves the user to nearest hospital (according to
nearest_hospital($x, y, $race)). $hitby is used for statistics...lookup_user($user_id) - Return user-array about $user_id.
is_friend($user_id) - Check if $user_id's owner is currently logged in's friend.
lookup_guild($guild_id) - Return guild-array about $guild_id.
_inventory_parser($inventory_db) - Originally intended for internal usage, hence the name. $inventory_db is $user['inventory'] (string). Returns an array in format $inventory['itemname'] = amount_of_carried_itemnames.
inventory_add($item, $count = 1, $user = NULL) - Add $count $item to $user's inventory. If $user is NULL, $user defaults to currently logged in player.
inventory_remove($item, $count = 1, $user = NULL) - See above, but removes $count $item from $user's inventory.
in_inventory($item, $count = 1, $user = NULL) - Check if $user (see above which player) is carrying $count $item.
pm_show_messages() - Show currently logged in player's PM-inbox.
log_message($message, $type, $target, $y=0) - Log $message. If $y is 0 (as it is by default), $target is considered as user's ID, if not, $target is location's X-coordinate. To $target (or the players who's at ($target,$y) at the moment of logging the message) the message shows up as "$type: $message". $type and $message can contain HTML-code.
name_colorer($user_id) - Returns appropiate 'style="color: #F00BAR"', according to $user_id's relationship to the currently logged in player.
hit_chance($base) - Enchaned coin. ($base)%+(player's level)% chance of hit. Return TRUE if hit, FALSE if not.
give_xp($amount, $target_id = NULL) - Give $amount XP to $target_id (cur. logged in if NULL).
Global variables
$db - Created by inc/db.php. It's a normal MySQLi-object.$map - 3x3-array of map. Center is in player's current position.
$user - User's array. Keys comes from user's row in DB.
Database Structure
hcs_acorn
ID - Self-explanatory. Auto_increment, uniquecoords - x|y (e.g 14|51)
requester - The uID behind the request.
magic - The amount of given magic when the requester is supposed to get the acorn.
hcs_forums
Store messages unformatted and unfiltered. kthxbai.pid - Post's ID. Auto_increment, unique.
tid - Topic ID the post belongs to.
text - The content of the post.
post_time - Send-time of the message in Unix-time (seconds since Epoch)
forum - Forum ID the post is in.
posted_by - uID of the sender of the post.
subject - Subject of the post.
attributes - Special the attributes the post/thread may have. Like sticky and lock.
hcs_guilds
gid - Guild ID. Auto_increment, uniquename - The guild's name.
description - The guild's description.
owner - uID of the owner of the guild.
tag - Guild's tag.
policy - The join-policy of the guild. c if closed (invite-only. Invites not done yet :)), o if open.
hcs_invites
This table is not in use yet.hcs_log
ID - Self-explanatory. Auto_increment, uniquetype - <b>thispart</b>: of the log-entry
content - <b>Explanation</b>: thispart
target - The receiver of the message. May be uID or coordinates in format (x,y) (e.g (24,52))
date - Unix-timestamp of when the log-entry was left.
hcs_news
ID - Self-explanatory. Auto_increment, uniquesubject - Newsitem's subject.
date - Unix-timestamp...
content - Newsitem's content.
hcs_pm
id - Self-explanatory. Auto_increment, uniqueto - Receiver's User ID.
from - Sender's User ID.
type - "pm" if it's a normal PM. "friend" if it's a friend-request.
time - Unix-timestamp of send-time.
subject - Subject of the message.
message - Content of the message.
hcs_sandbox
x - X-coordinate.y - Y-coordinate.
name - Block's name.
speciality - "The thing" of the block. 0 = nothing, 1 = street, 2 = building, 3 = police department, 4 = hospital.
belongs_to - The owner-side of the block. 0 = neutral. Below that are controlled by evil people. Above, good.
hcs_techs
name - The tech-module's name. Forced to be unique by the way filesystems tend to work. :)human_name - Human-readable name.
type - weapon/item/other. For now.
available - Which people can use it? Can be race's ID, "evil", "good" or "all".
comment - The description of the item.
found_from - The block-types the piece of tech can be found from. If empty, people are always carrying it.
hcs_users
uID - Self-explanatory. Auto_increment, uniqueTonsOfSelfExplanatoryColumns - If you can't tell what the undocumented column's idea is, you're not supposed to develop any code.
gold - Not in use.
in_out - c if player is inside, o if (s)he's not.
avatar - URL to the avatar.
admin_stuff - 0 to member users, higher than that if the player has special priviledges.
guild - Guild ID of the guild player is in. 0 if player isn't member of any guild.
ap_debt - The amount of APs player "owes". Efficiently makes sure the player can't do pretty much anything while dead...
locators - List of User IDs who are friends of the player.
lastrefresh - Last time the player hit a page.
Guidelines
- Use 4-space-indentation. It's not necessary, but it's used everywhere else...
- If data comes from user/browser ($_SESSION, $_POST, $_GET) and it's going to database. ESCAPE IT! (
$string = DBEscape($string)) - Filter/Format texts when they're FETCHED from the DB.
SVN
SVN-repo is at http://nindra.artemis-fowl.net/hcs/. Usesvn co http://nindra.artemis-fowl.net/hcs/trunk to fetch latest code.