Changeset 6319311 in network-game for common


Ignore:
Timestamp:
Oct 1, 2013, 3:56:03 PM (11 years ago)
Author:
Dmitry Portnoy <dportnoy@…>
Branches:
master
Children:
373089e
Parents:
0693e25
Message:

Some redfinition issues related to winsock2 are fixed and a few allegro rendering functions are now in GameRender

Location:
common
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • common/Common.cpp

    r0693e25 r6319311  
    33#include <sstream>
    44#include <cmath>
    5 
    6 #if defined WINDOWS
    7    #include <Windows.h>
    8 #endif
    9 
    105#include <ctime>
    116
  • common/Common.h

    r0693e25 r6319311  
    66#if defined WINDOWS
    77   #include <winsock2.h>
    8    #include <WS2tcpip.h>
     8   #include <ws2tcpip.h>
    99#elif defined LINUX
    1010   #include <fcntl.h>
  • common/Game.cpp

    r0693e25 r6319311  
    22
    33#include <allegro5/allegro_primitives.h>
    4 
    5 #include "Common.h"
    64
    75using namespace std;
     
    7876   this->blueScore = score;
    7977}
    80 
    81 void Game::drawPlayers(ALLEGRO_FONT* font, unsigned int curPlayerId) {
    82    map<unsigned int, Player*>::iterator it;
    83 
    84    Player* p;
    85    POSITION pos;
    86    ALLEGRO_COLOR color;
    87 
    88    for(it = players.begin(); it != players.end(); it++)
    89    {
    90       p = it->second;
    91 
    92       if (p->isDead)
    93          continue;
    94 
    95       pos = mapToScreen(p->pos.toInt());
    96 
    97       if (p->id == curPlayerId)
    98          al_draw_filled_circle(pos.x, pos.y, 14, al_map_rgb(0, 0, 0));
    99      
    100       if (p->team == 0)
    101          color = al_map_rgb(0, 0, 255);
    102       else if (p->team == 1)
    103          color = al_map_rgb(255, 0, 0);
    104      
    105       al_draw_filled_circle(pos.x, pos.y, 12, color);
    106 
    107       // draw player class
    108       int fontHeight = al_get_font_line_height(font);
    109 
    110       string strClass;
    111       switch (p->playerClass) {
    112       case Player::CLASS_WARRIOR:
    113          strClass = "W";
    114          break;
    115       case Player::CLASS_RANGER:
    116          strClass = "R";
    117          break;
    118       case Player::CLASS_NONE:
    119          strClass = "";
    120          break;
    121       default:
    122          strClass = "";
    123          break;
    124       }
    125       al_draw_text(font, al_map_rgb(0, 0, 0), pos.x, pos.y-fontHeight/2, ALLEGRO_ALIGN_CENTRE, strClass.c_str());
    126 
    127       // draw player health
    128       al_draw_filled_rectangle(pos.x-12, pos.y-24, pos.x+12, pos.y-16, al_map_rgb(0, 0, 0));
    129       if (p->maxHealth != 0)
    130          al_draw_filled_rectangle(pos.x-11, pos.y-23, pos.x-11+(22*p->health)/p->maxHealth, pos.y-17, al_map_rgb(255, 0, 0));
    131 
    132       if (p->hasBlueFlag)
    133          al_draw_filled_rectangle(pos.x+4, pos.y-18, pos.x+18, pos.y-4, al_map_rgb(0, 0, 255));
    134       else if (p->hasRedFlag)
    135          al_draw_filled_rectangle(pos.x+4, pos.y-18, pos.x+18, pos.y-4, al_map_rgb(255, 0, 0));
    136    }
    137 }
  • common/Game.h

    r0693e25 r6319311  
    44#include "Compiler.h"
    55
    6 #if defined WINDOWS
    7    #include <winsock2.h>
    8    #include <WS2tcpip.h>
    9 #elif defined LINUX
    10    #include <netinet/in.h>
    11 #endif
    12 
    136#include <string>
    147#include <map>
     8
     9#ifdef WINDOWS
     10   #define WIN32_LEAN_AND_MEAN
     11#endif
    1512
    1613#include <allegro5/allegro_font.h>
     
    4845   void setBlueScore(int score);
    4946   void setRedScore(int score);
    50 
    51    void drawPlayers(ALLEGRO_FONT* font, unsigned int curPlayerId);
    5247};
    5348
  • common/MessageContainer.cpp

    r0693e25 r6319311  
    22
    33#include <iostream>
    4 
    5 #include "Compiler.h"
    64
    75using namespace std;
  • common/MessageContainer.h

    r0693e25 r6319311  
    22#define _MESSAGE_CONTAINER_H
    33
    4 #include "Compiler.h"
    5 
    64#include <string>
    75
    8 #if defined WINDOWS
    9    #include <winsock2.h>
    10    #include <WS2tcpip.h>
    11 #elif defined LINUX
    12    #include <netinet/in.h>
    13 #endif
     6#include "Common.h"
    147
    158using namespace std;
  • common/MessageProcessor.cpp

    r0693e25 r6319311  
    33#include <iostream>
    44#include <fstream>
    5 
    6 #include "Common.h"
    75
    86MessageProcessor::MessageProcessor() {
  • common/Player.h

    r0693e25 r6319311  
    11#ifndef _PLAYER_H
    22#define _PLAYER_H
    3 
    4 #include "Compiler.h"
    5 
    6 #if defined WINDOWS
    7    #include <winsock2.h>
    8    #include <WS2tcpip.h>
    9 #elif defined LINUX
    10    #include <netinet/in.h>
    11 #endif
    123
    134#include <string>
  • common/Projectile.h

    r0693e25 r6319311  
    11#ifndef _PROJECTILE_H
    22#define _PROJECTILE_H
    3 
    4 #include "Compiler.h"
    53
    64#include <string>
  • common/WorldMap.h

    r0693e25 r6319311  
    33
    44#include <string>
    5 
    65#include <vector>
    76
Note: See TracChangeset for help on using the changeset viewer.