Пример #1
0
const char* File_ReadStringBack(sc_File *fil) {
  Stream *in = get_valid_file_stream_from_handle(fil->handle, "File.ReadStringBack");
  if (in->EOS()) {
    return CreateNewScriptString("");
  }

  int lle = in->ReadInt32();
  if ((lle >= 20000) || (lle < 1))
    quit("!File.ReadStringBack: file was not written by WriteString");

  char *retVal = (char*)malloc(lle);
  in->Read(retVal, lle);

  return CreateNewScriptString(retVal, false);
}
Пример #2
0
void File_ReadRawLine(sc_File *fil, char* buffer) {
  Stream *in = get_valid_file_stream_from_handle(fil->handle, "File.ReadRawLine");
  check_strlen(buffer);
  int i = 0;
  while (i < MAXSTRLEN - 1) {
    buffer[i] = in->ReadInt8();
    if (buffer[i] == 13) {
      // CR -- skip LF and abort
      in->ReadInt8();
      break;
    }
    if (buffer[i] == 10)  // LF only -- abort
      break;
    if (in->EOS())  // EOF -- abort
      break;
    i++;
  }
  buffer[i] = 0;
}
Пример #3
0
  int wloadsprites(color * pall, char *filnam, Bitmap ** sarray, int strt, int eend)
  {
    int vers;
    char buff[20];
    int numspri = 0, vv, hh, wdd, htt;

    Stream *in = Common::AssetManager::OpenAsset(filnam);
    if (in == NULL)
      return -1;

    vers = in->ReadInt16();
    in->ReadArray(&buff[0], 13, 1);
    for (vv = 0; vv < 256; vv++)        // there's a filler byte
      in->ReadArray(&pall[vv], 3, 1);

    if (vers > 4)
      return -1;

    if (vers == 4)
      numspri = in->ReadInt16();
    else {
      numspri = in->ReadInt16();
      if ((numspri < 2) || (numspri > 200))
        numspri = 200;
    }

    for (vv = strt; vv <= eend; vv++)
      sarray[vv] = NULL;

    for (vv = 0; vv <= numspri; vv++) {
      int coldep = in->ReadInt16();

      if (coldep == 0) {
        sarray[vv] = NULL;
        if (in->EOS())
          break;

        continue;
      }

      if (in->EOS())
        break;

      if (vv > eend)
        break;

      wdd = in->ReadInt16();
      htt = in->ReadInt16();
      if (vv < strt) {
          in->Seek(Common::kSeekCurrent, wdd * htt);
        continue;
      }
      sarray[vv] = BitmapHelper::CreateBitmap(wdd, htt, coldep * 8);

      if (sarray[vv] == NULL) {
        delete in;
        return -1;
      }

      for (hh = 0; hh < htt; hh++)
        in->ReadArray(&sarray[vv]->GetScanLineForWriting(hh)[0], wdd * coldep, 1);
    }
    delete in;
    return 0;
  }