// we are expected to move mark & parserMark relative to any moved characters, set currentChar to the first new character fetched, update bufferLength, and advance currentByte as appropriate. Does not check for EOF; it is the caller's responsibility to verify this. static void fillCharacterBuffer(_CFXMLInputStream *stream) { if (!stream->charBuffer) { growCharacterBuffer(stream); } if (!stream->mark && !stream->parserMark) { // This is the easy case; we can freely overwrite the buffer; if either mark or parserMark is set, we must not remove any characters from those marks and the end of the buffer CFIndex fillLength = stream->bufferCapacity-5; // We leave a few characters at the end, b/c we don't want to reallocate (doubling the amount of memory used) just b/c we're matching a small string near the end of the filled buffer stream->bufferLength = loadCharacters(stream->charBuffer, fillLength, stream); CFAssert(stream->bufferLength != 0, __kCFLogAssertion, "CF internal error: XML parser input stream corruption"); stream->currentChar = stream->charBuffer; } else { // We do everything we can not to allocate; first we fill any remaining characters. If that doesn't work, we try shifting the characters starting at the earlier of mark or parserMark to the beginning of buffer, then filling the newly-freed characters. Boolean done; // First try just filling the remaining capacity done = (fillToCapacity(stream) != 0); if (!done) { const UniChar *leftMostMark; if (stream->mark && !stream->parserMark) { leftMostMark = stream->mark; } else if (stream->parserMark && !stream->mark) { leftMostMark = stream->parserMark; } else if (stream->parserMark < stream->mark) { leftMostMark = stream->parserMark; } else { leftMostMark = stream->mark; } if (leftMostMark > stream->charBuffer) { CFIndex delta = leftMostMark - stream->charBuffer; memmove(stream->charBuffer, leftMostMark, (stream->bufferLength - delta) * sizeof(UniChar)); stream->bufferLength -= delta; if (stream->mark) { stream->mark -= delta; } if (stream->parserMark) { stream->parserMark -= delta; } // Now try to fill the newly-opened space done = (fillToCapacity(stream) != 0); delta = loadCharacters(stream->charBuffer + stream->bufferLength, stream->bufferCapacity - stream->bufferLength, stream); } } if (!done) { // No help for it; now we must allocate growCharacterBuffer(stream); fillToCapacity(stream); // If this doesn't work, we give up. } } }
// returns number of characters filled CF_INLINE CFIndex fillToCapacity(_CFXMLInputStream *stream) { CFIndex numFilled; if (stream->bufferLength >= stream->bufferCapacity) return 0; // Try and fill in the remaining characters numFilled = loadCharacters(stream->charBuffer+stream->bufferLength, stream->bufferCapacity - stream->bufferLength, stream); if (numFilled != 0) { stream->currentChar = stream->charBuffer + stream->bufferLength; stream->bufferLength += numFilled; } return numFilled; }
bool Zone::load(QString path, QString name) { m_info.name = name; // Load the main archive and WLD file. QString zonePath = QString("%1/%2.s3d").arg(path).arg(name); QString zoneFile = QString("%1.wld").arg(name); m_mainArchive = new PFSArchive(zonePath); m_mainWld = WLDData::fromArchive(m_mainArchive, zoneFile); // Load the zone's terrain. m_terrain = new ZoneTerrain(this); if(!m_terrain->load(m_mainArchive, m_mainWld)) { delete m_terrain; m_terrain = NULL; return false; } // Load the zone's static objects. m_objects = new ZoneObjects(this); if(!m_objects->load(path, name, m_mainArchive)) { delete m_objects; m_objects = NULL; return false; } m_actorTree = new OctreeIndex(m_objects->bounds(), 8); m_objects->addTo(m_actorTree); // Load the zone's light sources. if(!importLightSources(m_mainArchive)) return false; // Load the zone's characters. QString charPath = QString("%1/%2_chr.s3d").arg(path).arg(name); QString charFile = QString("%1_chr.wld").arg(name); loadCharacters(charPath, charFile); // Load the zone's sound triggers. QString triggersFile = QString("%1/%2_sounds.eff").arg(path).arg(name); SoundTrigger::fromFile(m_soundTriggers, triggersFile); return true; }
void main() { char j; unsigned int *seed; backupPageZero(); io_needed=0; loadCharacters(); loadTextesItems(); seed = (unsigned int *) 630; // timer srand(*seed); j = rand(); camping(); io_needed = 1; saveCharacters(); restorePageZero(); SwitchToCommand("LABY"); //SwitchToCommand("!DIR"); }
void main() { char j, a; unsigned int *seed; backupPageZero(); GenerateTables(); DiscLoad("FONT.BIN"); // testing //sedoric("!LOAD(\"TEAM.BIN\")"); //cls(); #ifdef debug printf("char : %d, short %d, int %d, long %d, float %d\n", sizeof(char), sizeof(short), sizeof(int), sizeof(long), sizeof(float)); printf("taper sur une touche pour continuer\n"); a = (char)getchar(); #endif io_needed = 1; loadCharacters(); #ifdef debug printf("taper sur une touche pour continuer\n"); a = (char)getchar(); #endif loadLaby(); if (ca==0) { if (c[x+y*XMAX] != 0) { unsigned char nb = 255; // un coffre ou un combat a été fini char cas = c[x+y*XMAX]; if (cas>=21 && cas<=28) nb = cas - 21; else if (cas >=30 && cas <= 50) nb = cas - 30 + 8; // les 8 premiers bits stockent les coffres if (nb < 40) { SetBit(combats_coffres[ville-1], nb); //printf("Coffre ou Combat %d fini!\n", nb); c[x+y*XMAX] = 0; } } } #ifdef debug for (a=0; a<8; a++) for (j=0; j<40; j++) if(TestBit(combats_coffres[a], j)) printf("Bit %d is set\n", j); // testing // SetBit(combats_coffres[ville-1], 0); #endif printf("Taper sur une touche pour continuer\n"); get(); seed = (unsigned int *) 630; // timer srand(*seed); #ifdef debug printf("timer vaut %d\n", *seed); printf("alea vaut %d\n", rand()); printf("taper sur une touche pour continuer\n"); a = (char)getchar(); #endif // Sedoric(command2); // 330 CASE=C(X,Y) prep(); drawLaby(); ca = c[x+y*XMAX]; // manageCell(); // 320 GOSUB 500:GOSUB 1000 while(1) { // 380 GET A$ //a = (char)getchar(); //printf("x=%d, y=%d, s=%d ca=%d\n", x,y,s,ca); a = get(); switch(a) { //#ifdef debug case 'F': // pour debug case 'f': // 390 IF A$="F" THEN END a = 'F'; text(); io_needed = 1; saveCharacters(); restorePageZero(); printf("sauvegarde ok\n"); SwitchToCommand("!DIR"); // évite une erreur bizarre return; break; //#endif case ' ': // 400 IF A$=" "AND F(1)>1 AND F(1)<7 THEN GOSUB 3000:GOTO 330 if(f[0]>1&&f[0]<7) { #ifdef debug for (j=0;j<4;j++) { printf("cle(%d,%d) = %d ", 3, j, cles[3][j]); } #endif // 3000 REM ClÈ // 3010 IF F(1)=2 THEN 3030 // 3020 IF CLEF(VIL,(F(1)-2))=0 THEN ZAP:PRINT TX$(4):GOTO 3050 // 3030 F(1)=0:GOSUB 600:PING // 3050 RETURN if (f[0] == 2) { f[0]=0; forward(); ping(); // on avance deux fois prep(); printf("On passe la porte\n"); wait(180); drawLaby(); forward(); } else { ////// MODIF Maximus ******* if(cles[ville-1][f[0]-3]==0) { zap(); printf("Ou est la cl{ ?\n"); } else { #ifdef debug printf("Porte %d cle(%d,%d) %d ", f[0], ville-1, (f[0]-3), cles[ville-1][f[0]-3]); a = (char)getchar(); #endif InvertBit(&dedans,f[0]-3); f[0]=0; forward(); ping(); // on avance deux fois prep(); printf("On passe la porte\n"); wait(180); drawLaby(); forward(); } } } break; case 'I': case 'i': case 'Z': case 'z': // 410 IF A$="I" OR A$="i" THEN GOSUB 600:GOTO 330 forward(); break; case 'J': case 'j': case 'Q': case 'q': // 420 IF A$="J" OR A$="j" THEN S=S-1:IF S=0 THEN S=4 s--; if(s<0) s=3; prep(); drawLaby(); break; case 'L': case 'l': case 'D': case 'd': // 430 IF A$="L" OR A$="l" THEN S=S+1:IF S=5 THEN S=1 s++; if(s>3) s=0; prep(); drawLaby(); break; case 'C': case 'c': // 435 IF A$="C" THEN GOTO 21000 text(); io_needed = 1; saveCharacters(); restorePageZero(); SwitchToCommand("CAMP"); break; //#ifdef debug case 'A': case 'a': printf("alea vaut %d\n", rand()); break; case 'K': case 'k': for (j=0;j<4;j++) { cles[ville-1][j] = !cles[ville-1][j]; } break; case 'V': case 'v': text(); io_needed = 1; saveCharacters(); restorePageZero(); SwitchToCommand("VILLE"); break; //#endif default: puts("I:avance, J:droite, L:gauche\nESPACE: ouvrir porte"); wait(200); } // 450 GOTO 300 } }