Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8535 in orxonox.OLD for branches/bsp_model/src


Ignore:
Timestamp:
Jun 16, 2006, 3:48:22 PM (19 years ago)
Author:
patrick
Message:

bsp: other file reading algorithm used, seems to work perfectly

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/bsp_model/src/lib/graphics/importer/md3/md3_animation_cfg.cc

    r8534 r8535  
    2121#include "debug.h"
    2222
     23#include <stdio.h>
     24#include <stdlib.h>
     25
    2326using namespace std;
    2427
     
    4043  MD3AnimationCfg::MD3AnimationCfg(std::string filename)
    4144  {
    42     this->dataStream.open(filename.c_str());
    43 
    44     if( !this->dataStream) {
    45       PRINTF(1)("Error: file could not be opened: %s\n", filename.c_str());
    46       return;
    47     }
     45
    4846
    4947    this->loadConfig(filename);
     
    7270
    7371
     72    //this->dataStream.open(filename.c_str());
     73    FILE* pFile;
     74    char* cLine;
     75    size_t len = 0;
     76    ssize_t read = 0;
     77
     78    PRINTF(0)("opening file: %s\n", filename.c_str());
     79    pFile = fopen(filename.c_str(), "r");
     80    if( !pFile) {
     81      PRINTF(1)("Error: file could not be opened: %s\n", filename.c_str());
     82      return;
     83    }
     84
    7485
    7586    // parse file
    76     this->dataStream.getline(buffer, 1024, '\n');
    77     std::string line(buffer);
    78     PRINTF(0)("line = %s\n", line.c_str());
    79     while( !this->dataStream.eof()) {
     87//     this->dataStream.getline(buffer, 1024, '\n');
     88//     std::string line(buffer);
     89    while( (read = getline(&cLine, &len, pFile)) != -1) { /*( !this->dataStream.eof()) {*/
     90      std::string line(cLine);
    8091
    8192      //ignore empty lines and comments
     
    8495        if( inHeader && line.find("sex") == 0) {
    8596          //parse line: sex [m | f | ...]
    86 //           StringTokenizer st=new StringTokenizer(line, " \t\n\r\f/");
    8797          std::vector<std::string> tokens;
    8898          Tokenizer::tokenize(line, tokens, " \t\n\r\f/");
    8999
     100          PRINTF(0)("size = %i, line = |%s|\n", read, line.c_str());
     101
    90102          while( !tokens.empty())
    91103          {
    92             PRINTF(0)("tokens: %s\n", tokens.back());
     104            PRINTF(0)("tokens: %s\n", tokens.back().c_str());
    93105            tokens.pop_back();
    94106          }
     
    96108        }
    97109      }
    98       this->dataStream.getline(buffer, 1024, '\n');
    99       std::string line(buffer);
    100110    }
    101111/*
Note: See TracChangeset for help on using the changeset viewer.