Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2105 in orxonox.OLD for orxonox/branches/chris/src/command_node.cc


Ignore:
Timestamp:
Jul 11, 2004, 3:14:52 PM (20 years ago)
Author:
chris
Message:

orxonox/branches/chris: Port to SDL complete. Everything compiles and the generated executable runs without crashing. Keyboard and mouse handling works. Drawing is messed up, possibly because of my incompetent Rotation class. Hence all you see at them moment is a pitch black screen. I added the makefile I used to compile it since bensch hasn't yet included SDL into the configure script.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/chris/src/command_node.cc

    r2100 r2105  
    2222#include <stdio.h>
    2323#include <strings.h>
     24#include <stdlib.h>
    2425
    2526using namespace std;
     
    5253        FILE* stream;
    5354       
     55        printf("Loading key bindings from %s\n", filename);
     56       
    5457        if( filename == NULL) filename = DEFAULT_KEYBIND_FILE;
    5558       
     
    7376        char namebuf[256];
    7477        char valuebuf[256];
     78        memset (namebuf, 0, 256);
     79        memset (valuebuf, 0, 256);
    7580        int* index;
    7681
     
    8186                {
    8287                        case 0:
     88                                printf("Key binding %d(%s) set to %s\n", index[1], SDLK_to_keyname( index[1]), valuebuf);
    8389                                strcpy (aliases->keys[index[1]], valuebuf);
    8490                                break;
    8591                        case 1:
     92                                printf("Button binding %d(%s) set to %s\n", index[1], SDLB_to_buttonname( index[1]), valuebuf);
    8693                                strcpy (aliases->buttons[index[1]], valuebuf);
    8794                                break;
     
    8996                                break;
    9097                }
     98                memset (namebuf, 0, 256);
     99                memset (valuebuf, 0, 256);
    91100        }
    92101}
     
    105114{
    106115        coord[0] = -1;
    107         if( (coord[1] = keyname_to_SDLK (name)) != -1) coord[0] = 0;
    108         if( (coord[1] = buttonname_to_SDLB (name)) != -1) coord[0] = 1;
     116        coord[1] = -1;
     117        int c;
     118        if( (c = keyname_to_SDLK (name)) != -1)
     119        {
     120                coord[1] = c;
     121                coord[0] = 0;
     122        }
     123        if( (c = buttonname_to_SDLB (name)) != -1)
     124        {
     125                coord[1] = c;
     126                coord[0] = 1;
     127        }
    109128        return coord;
    110129}
     
    112131void CommandNode::process ()
    113132{
     133perror("CommandNode|process()");
    114134        if( bLocalInput) process_local ();
    115135        else process_network ();
     
    123143        while( SDL_PollEvent (&event))
    124144        {
     145                memset (cmd.cmd, 0, CMD_LENGHT);
    125146                switch( event.type)
    126147                {
     
    173194void CommandNode::relay (Command* cmd)
    174195{
     196perror("CommandNode|relay()");
    175197        List<WorldEntity>* plist = bound;
    176198       
     199        Orxonox *orx = Orxonox::getInstance();
     200        if( orx->system_command (cmd)) return;
     201               
    177202        if( bLocalInput) send_over_network (cmd);
    178203       
Note: See TracChangeset for help on using the changeset viewer.