Open main menu

CDOT Wiki β

UNX511 - 20121 - Project - TeamA

Revision as of 22:14, 4 March 2012 by Rainulf (talk | contribs) (added db schema)

Project Description

Ganglands is a massively multiplayer online game that combines the best features of classic multi-user dungeons with the excitement of crime sim RPGs like Mob Wars. Players compete to become the greatest mob boss in the ganglands by forging alliances, engaging in combat, and solving devious puzzles. Each task successfully accomplished garners experience points and money, which can be used to level up your characters and buy tools and manpower that help you claw your way to the top. Ongoing contests give you access to special bonuses and a leaderboard keeps track of your various accomplishments. Ganglands operates on a Linux server coded in C and C++, with a C/++ curses-based text frontent and web (HTML5) and Android(Java)-based graphical frontends. It is currently in its planning stages, with a projected public release date of late April 2012, at which point the source code will be released under an open source license. This wiki serves as a chronicle of its development and a repository for important information for developers. Please check back often for updates.

Team Members

First Name Last Name Seneca Id wiki id IRC nick
Natesh Mayuranathan nmayuranathan Nmayuranathan Tesh_
Rainulf Pineda Rainulf Rainulf _Rainulf
Lucas Alba Bresso Lucas Lucas N/A
Ahmad Ali Ahmad Ahmad N/A

Development Plan (Rough)

  • Project planning (Jan 11)
  • Game interface/interaction planning (Jan 18)
  • Game design/technical programming design (Jan 25)
    • C++/OO design
    • Socket OO design - accepting connections
    • Main game design
    • Putting the socket and the main game design together
  • R0.1 - basic chat serving capability and in-game displays (Feb. 13)

Useful Code Snippets

Basic HTTP Server

HTTP Server Encapsulated in Classes


SQL Schema

CREATE TABLE unx511.avatars (
    id int unsigned not null auto_increment,
    username varchar(20) not null,
    password varchar(40) not null,
    level tinyint unsigned not null default 1, 
    lvl_points int unsigned default 0,
    health int unsigned not null default 100,
    HP int unsigned not null default 1,
    cash decimal default 0,
    banked double default 0,
    primary key (id)
) ENGINE = InnoDB; 

CREATE TABLE unx511.avatar_attack (
    id int unsigned not null auto_increment,
    attacker_id int unsigned not null,
    victim_id int unsigned not null,
    winner int not null,
    attack_date datetime not null,
    primary key (id),
    foreign key (attacker_id) references avatars (id),
    foreign key (victim_id) references avatars (id)
)  ENGINE = InnoDB;

CREATE TABLE unx511.hitlist (
    id int unsigned not null auto_increment,
    placed_hit int unsigned not null,
    person_to_beat int unsigned not null,
    amount_paid decimal not null,
    paid_date datetime not null,
    active ENUM('Y', 'N') not null,
    beat_by int unsigned not null,
    primary key (id),
    foreign key (placed_hit) references avatars (id),
    foreign key (person_to_beat) references avatars (id)
)  ENGINE = InnoDB;

CREATE TABLE unx511.missions (
    id int unsigned not null auto_increment,
    name varchar(256) not null,
    description varchar(1024),
    pay_amount decimal not null,
    score_to_beat int not null,
    attack_points int not null,
    defence_points int not null,
    exp float not null, 
    loot decimal not null,
    primary key (id)
) ENGINE = InnoDB;

CREATE TABLE unx511.item (
    id int unsigned not null auto_increment,
    name varchar(256) not null,
    attack_points int unsigned null,
    defence_points int unsigned null,
    cost decimal unsigned not null,
    primary key (id)
) ENGINE = InnoDB;

CREATE TABLE unx511.avatar_item (
    id int unsigned not null auto_increment,
    avatar_id int unsigned not null,
    item_id int unsigned not null,
    amount int not null default 0,  # how many of items exist in user inventory
    amount_paid decimal not null,   # is this necessary? since each item has a cost associated with it
    # date    -- if there are multiple items how does date work?
    primary key (id),
    foreign key (avatar_id) references avatars (id),
    foreign key (item_id) references item (id)
) ENGINE = InnoDB;

CREATE TABLE unx511.avatar_mission (
    id int unsigned not null auto_increment,
    avatar_id int unsigned not null,
    mission_id int unsigned not null,
    mission_date datetime not null,
    primary key (id),
    foreign key (avatar_id) references avatars (id),
    foreign key (mission_id) references missions (id)
) ENGINE = InnoDB;

Common server functions

 * Runs a linux command, reallocates memory for whatever the command outputs
 * @author Rainulf
 * @return character pointer to the allocated memory
 * @note needs to be free()'d after use
char* runCmd(const char* cmd){
   FILE* fp;
   char* out = NULL;
   char* more_out;
   char ch;
   int count = 0;

  /* Open the command for reading. */
   fp = popen(cmd, "r");
   if (fp == NULL) {
      printf("Failed to run command\n" );
      return 0;

   /* Read the output a line at a time - output it. */
   ch = fgetc(fp);
   while(ch != '\n' && ch != EOF){
      more_out = (char*) realloc(out, ++count); // no need to free more_out

      if(more_out != NULL){
         out = more_out;
         out[count-1] = ch;
      ch = fgetc(fp);
   return out;

 * Concatenates two strings by allocating memory for the two
 * @author Rainulf
 * @return concatenated string - dynamically allocated
 * @note needs to be free()'d after use
char* concat(const char* a, const char* b){
   char* tmp = malloc(snprintf(NULL, 0, "%s %s", a, b) + 1);
   sprintf(tmp, "%s %s", a, b);
   return tmp;

 * Gets input from STDIN character by character until '\n' or MAXLEN is reached, puts into the character pointer str
 * @author Rainulf
 * @return n/a
 * @note MAXLEN have to be defined
void getInput(char* str){
   int charCount = 0;
   char ch;
   // get input from user
   ch = getchar();
   while( (ch != '\n') && (charCount < MAXLEN) ) {
      str[charCount++] = ch;
      ch = getchar();
   str[charCount] = 0;

Text-Based Chat/MUD Client Demo


(Latest on top)

Tuesday, February 28, 2012

  • Venue: Skype
  • Agenda: Discussion of Project Report Submission, deadlines for project components

Tuesday, February 7, 2012

  • Venue: Skype
  • Agenda: Collaborative code/'hack' session on examples of components of project for a demo
  • Discussion of web client issues and potential solutions

Monday, February 6, 2012

  • Venue: Skype
  • Agenda (subject to change):
  • Clearly define project concept and goals
    • At its core, the game is a MUD which merges features of 'crime sim' role-playing games (akin to Mob Wars)}
    • Players log into a client (Curses/Web/Android)
    • Server displays instructions and listens for commands
    • The goal is to become Godfather - leaderboards are established to track this
    • To reach this goal, users take Jobs and/or Hits for experience, and join a Gang
    • The combined wealth and experience of a Gang allow them to advance on a leaderboard
    • Periodically, a contest gives users the chance to acquire more money, more experience, and rare items - this makes it easier for them to advance and allows them to compete for more things
    • The game never ends. Any user can start up from scratch and eventually build up to a Godfather
  • Assign roles
    • Lucas/Natesh: C/++ Server Leads
    • Natesh: C++ Curses Client Lead
    • Rainulf: Web Client Lead
    • Ahmad: Other roles as necessary
    • Everyone: Contributions to C/++ Server
  • Plan roadmap and deadlines, noting that midterm and Stage 1 project document submission is on Wednesday, February 22, 2012
    • Current goal: Text-based chat client - Wednesday, Feb 8, 2012
  • Next Meeting: Tomorrow, Tuesday, February 7, 2012

Saturday, January 28, 2012

  • Venue: Skype
  • Topics: Requirements Assessment, Project Planning
  • Database access was discussed - MySQL's C API will be used
  • Rainulf suggested that we set up a server for development with root access (for port 80 and installation of additional tools)
  • Gameplay processes were discussed in detail
  • what will the player experience when they launch a client?
    • on first launch, a short intro is displayed with basic gameplay instructions; other times description of current location
  • how will player data be stored? - JSON string is parsed using Jansson library and passed to database using MySQL's C API
  • what happens when players log out?
  • Ideas for gameplay were fleshed out
  • methods for player advancement and goals
  • combat mechanics
  • quests
  • a location is described (text that displays when they "look") and a task to perform there
  • First release is scheduled for Feb 13


Database Schema