示例#1
0
StackHandler *loadStackRef(Common::SeekableReadStream *stream) {
	StackHandler *nsh;

	if (stream->readByte()) {    // It's one we've loaded already...
		nsh = getStackFromLibrary(stream->readUint16BE());
		nsh->timesUsed++;
	} else {
		// Load the new stack

		nsh = new StackHandler;
		if (!checkNew(nsh))
			return NULL;
		nsh->last = NULL;
		nsh->first = loadStack(stream, &nsh->last);
		nsh->timesUsed = 1;

		// Add it to the library of loaded stacks

		stackLibrary *s = new stackLibrary;
		if (!checkNew(s))
			return NULL;
		s->stack = nsh;
		s->next = stackLib;
		stackLib = s;
		stackLibTotal++;
	}
	return nsh;
}
示例#2
0
personaAnimation * createPersonaAnim (int num, variableStack * & stacky) {
	personaAnimation * newP = new personaAnimation;
	checkNew (newP);

	newP -> numFrames = num;
	newP -> frames = new animFrame[num];
	checkNew (newP -> frames);

	int a = num, frameNum, howMany;

	while (a) {
		a --;
		newP -> frames[a].noise = 0;
		if (stacky -> thisVar.varType == SVT_FILE) {
			newP -> frames[a].noise = stacky -> thisVar.varData.intValue;
		} else if (stacky -> thisVar.varType == SVT_FUNC) {
			newP -> frames[a].noise = - stacky -> thisVar.varData.intValue;
		} else if (stacky -> thisVar.varType == SVT_STACK) {
			getValueType (frameNum, SVT_INT, stacky -> thisVar.varData.theStack -> first -> thisVar);
			getValueType (howMany, SVT_INT, stacky -> thisVar.varData.theStack -> first -> next -> thisVar);
		} else {
			getValueType (frameNum, SVT_INT, stacky -> thisVar);
			howMany = 1;
		}
		trimStack (stacky);
		newP -> frames[a].frameNum = frameNum;
		newP -> frames[a].howMany = howMany;
	}

	return newP;
}
示例#3
0
personaAnimation * copyAnim (personaAnimation * orig) {
	int num = orig -> numFrames;

	personaAnimation * newAnim	= new personaAnimation;
	if (! checkNew (newAnim)) return NULL;

	// Copy the easy bits...
	newAnim -> theSprites		= orig -> theSprites;
	newAnim -> numFrames		= num;

	if (num) {

		// Argh! Frames! We need a whole NEW array of animFrame structures...

		newAnim->frames = new animFrame[num];
		if (! checkNew (newAnim->frames)) return NULL;

		for (int a = 0; a < num; a ++) {
			newAnim -> frames[a].frameNum = orig -> frames[a].frameNum;
			newAnim -> frames[a].howMany = orig -> frames[a].howMany;
			newAnim -> frames[a].noise = orig -> frames[a].noise;
		}
	} else {
		newAnim -> frames = NULL;
	}

	return newAnim;
}
示例#4
0
void fixFont (spritePalette & spal) {

	delete [] spal.tex_names;
	delete [] spal.burnTex_names;
	delete [] spal.tex_h;
	delete [] spal.tex_w;
	
	spal.numTextures = theFont.myPalette.numTextures;

	spal.tex_names = new GLuint [spal.numTextures];
	if (! checkNew (spal.tex_names)) return;	
	spal.burnTex_names = new GLuint [spal.numTextures];
	if (! checkNew (spal.burnTex_names)) return;	
	spal.tex_w = new int [spal.numTextures];
	if (! checkNew (spal.tex_w)) return;	
	spal.tex_h = new int [spal.numTextures];
	if (! checkNew (spal.tex_h)) return;	
	
	for (int i = 0; i < theFont.myPalette.numTextures; i++) {
		spal.tex_names[i] = theFont.myPalette.tex_names[i];
		spal.burnTex_names[i] = theFont.myPalette.burnTex_names[i];
		spal.tex_w[i] = theFont.myPalette.tex_w[i];
		spal.tex_h[i] = theFont.myPalette.tex_h[i];
	}
}
示例#5
0
persona * getCostumeFromVar (variable & thisVar) {
	persona * p = NULL;

	switch (thisVar.varType) {
		case SVT_ANIM:
		p = new persona;
		if (! checkNew (p)) return NULL;
		p -> numDirections = 1;
		p -> animation = new personaAnimation * [3];
		if (! checkNew (p -> animation)) return NULL;

		for (int iii = 0; iii < 3; iii ++)
			p -> animation[iii] = copyAnim (thisVar.varData.animHandler);

		break;

		case SVT_COSTUME:
		return thisVar.varData.costumeHandler;
		break;

		default:
		fatal ("Expecting an animation variable; found variable of type", typeName[thisVar.varType]);
	}

	return p;
}
示例#6
0
bool loadFunctionCode (loadedFunction * newFunc) {
	unsigned int numLines, numLinesRead;
	int a;

	if (! openSubSlice (newFunc -> originalNumber)) return false;


	newFunc -> unfreezable	= fgetc (bigDataFile);
	numLines				= get2bytes (bigDataFile);
	newFunc -> numArgs		= get2bytes (bigDataFile);
	newFunc -> numLocals	= get2bytes (bigDataFile);
	newFunc -> compiledLines = new lineOfCode[numLines];
	if (! checkNew (newFunc -> compiledLines)) return false;

	for (numLinesRead = 0; numLinesRead < numLines; numLinesRead ++) {
		newFunc -> compiledLines[numLinesRead].theCommand = (sludgeCommand) fgetc (bigDataFile);
		newFunc -> compiledLines[numLinesRead].param = get2bytes (bigDataFile);
	}

	finishAccess ();

	// Now we need to reserve memory for the local variables

	newFunc -> localVars = new variable[newFunc -> numLocals];
	if (! checkNew (newFunc -> localVars)) return false;
	for (a = 0; a < newFunc -> numLocals; a ++) {
		initVarNew (newFunc -> localVars[a]);
	}
	return true;
}
示例#7
0
void LanguageManager::createTable(Common::File *fp) {
	// get number of languages
	_numLanguages =
				(gameVersion >= VERSION(1, 3)) ? (fp->readByte()) : 0;
	debugC(2, kSludgeDebugDataLoad, "numLanguages : %c", _numLanguages);

	// make language table
	_languageTable = new uint[_numLanguages + 1];
	if (!checkNew(_languageTable))
		return;

	_languageNames = new Common::String[_numLanguages + 1];
	if (!checkNew(_languageNames))
		return;

	for (uint i = 0; i <= _numLanguages; i++) {
		_languageTable[i] = i ? fp->readUint16BE() : 0;
		debugC(2, kSludgeDebugDataLoad, "languageTable %i: %i", i, _languageTable[i]);
		_languageNames[i].clear();
		if (gameVersion >= VERSION(2, 0)) {
			if (_numLanguages) {
				_languageNames[i] = readString(fp);
				debugC(2, kSludgeDebugDataLoad, "languageName %i: %s\n", i, _languageNames[i].c_str());
			}
		}
	}
}
示例#8
0
bool loadCostume (persona * cossy, FILE * fp) {
	int a;
	cossy -> numDirections = get2bytes (fp);
	cossy -> animation = new personaAnimation * [cossy -> numDirections * 3];
	if (! checkNew (cossy -> animation)) return false;
	for (a = 0; a < cossy -> numDirections * 3; a ++) {
		cossy -> animation[a] = new personaAnimation;
		if (! checkNew (cossy -> animation[a])) return false;

		if (! loadAnim (cossy -> animation[a], fp)) return false;
	}
//	debugCostume ("Loaded", cossy);
	return true;
}
示例#9
0
bool makeFastArraySize (variable & to, int size) {
	if (size < 0) return fatal ("Can't create a fast array with a negative number of elements!");
	unlinkVar (to);
	to.varType = SVT_FASTARRAY;
	to.varData.fastArray = new fastArrayHandler;
	if (! checkNew (to.varData.fastArray)) return false;
	to.varData.fastArray -> fastVariables = new variable[size];
	if (! checkNew (to.varData.fastArray -> fastVariables)) return false;
	for (int i = 0; i < size; i ++) {
		initVarNew (to.varData.fastArray -> fastVariables[i]);
	}
	to.varData.fastArray -> size = size;
	to.varData.fastArray -> timesUsed = 1;
	return true;
}
示例#10
0
int startNewFunctionNum (unsigned int funcNum, unsigned int numParamsExpected, loadedFunction * calledBy, variableStack * & vStack, bool returnSommet) {
	loadedFunction * newFunc = new loadedFunction;
	checkNew (newFunc);
	newFunc -> originalNumber = funcNum;

	loadFunctionCode (newFunc);

	if (newFunc -> numArgs != (int)numParamsExpected) return fatal ("Wrong number of parameters!");
	if (newFunc -> numArgs > newFunc -> numLocals) return fatal ("More arguments than local variable space!");

	// Now, lets copy the parameters from the calling function's stack...

	while (numParamsExpected) {
		numParamsExpected --;
		if (vStack == NULL) return fatal ("Corrupted file! The stack's empty and there were still parameters expected");
		copyVariable (vStack -> thisVar, newFunc -> localVars[numParamsExpected]);
		trimStack (vStack);
	}

	newFunc -> cancelMe = false;
	newFunc -> timeLeft = 0;
	newFunc -> returnSomething = returnSommet;
	newFunc -> calledBy = calledBy;
	newFunc -> stack = NULL;
	newFunc -> freezerLevel = 0;
	newFunc -> runThisLine = 0;
	newFunc -> isSpeech = 0;
	initVarNew (newFunc -> reg);

	restartFunction (newFunc);
	return 1;
}
示例#11
0
result_t XmlNodeList::replaceChild(XmlNode_base *newChild, XmlNode_base *oldChild,
                                   obj_ptr<XmlNode_base> &retVal)
{
    XmlNodeImpl *pNew = checkChild(newChild);
    XmlNodeImpl *pOld = checkChild(oldChild);
    if (!pNew || !pOld)
        return CHECK_ERROR(CALL_E_INVALIDARG);

    if (pOld->m_parent != m_this)
        return CHECK_ERROR(Runtime::setError("The node to be replaced is not a child of this node."));

    if (pNew == pOld)
    {
        retVal = newChild;
        return 0;
    }

    if (!checkNew(pNew))
        return CHECK_ERROR(Runtime::setError("The new child element contains the parent."));

    int32_t idx = pOld->m_index;

    pOld->clearParent();

    pNew->setParent(m_this, idx);
    m_childs[idx] = pNew;

    retVal = oldChild;
    return 0;
}
示例#12
0
LoadedSpriteBank *GraphicsManager::loadBankForAnim(int ID) {
	// Check if already exist
	LoadedSpriteBanks::iterator it;
	for (it = _allLoadedBanks.begin(); it != _allLoadedBanks.end(); ++it) {
		if ((*it)->ID == ID) {
			return (*it);
		}
	}

	// Else create a new sprite bank
	LoadedSpriteBank *returnMe = new LoadedSpriteBank;
	if (checkNew(returnMe)) {
		returnMe->ID = ID;
		if (loadSpriteBank(ID, returnMe->bank, false)) {
			returnMe->timesUsed = 0;
			debugC(3, kSludgeDebugDataLoad, "loadBankForAnim: New sprite bank created OK");
			_allLoadedBanks.push_back(returnMe);
			return returnMe;
		} else {
			debugC(3, kSludgeDebugDataLoad, "loadBankForAnim: I guess I couldn't load the sprites...");
			return nullptr;
		}
	} else
		return nullptr;
}
示例#13
0
bool addVarToStack (const variable & va, variableStack * & thisStack) {
	variableStack * newStack = new variableStack;
	if (! checkNew (newStack)) return false;

	if (! copyMain (va, newStack -> thisVar)) return false;
	newStack -> next = thisStack;
	thisStack = newStack;
	return true;
}
示例#14
0
bool addPerson (int x, int y, int objNum, persona * p) {
	onScreenPerson * newPerson = new onScreenPerson;
	if (! checkNew (newPerson)) return false;

	// EASY STUFF
	newPerson -> thisType = loadObjectType (objNum);
	newPerson -> scale = 1;
	newPerson -> extra = 0;
	newPerson -> continueAfterWalking = NULL;
	moveAndScale (* newPerson, x, y);
	newPerson -> frameNum = 0;
	newPerson -> walkToX = x;
	newPerson -> walkToY = y;
	newPerson -> walking = false;
	newPerson -> spinning = false;
	newPerson -> show = true;
	newPerson -> direction = 0;
	newPerson -> angle = 180;
	newPerson -> wantAngle = 180;
	newPerson -> angleOffset = 0;
	newPerson -> floaty = 0;
	newPerson -> walkSpeed = newPerson -> thisType -> walkSpeed;
	newPerson -> myAnim = NULL;
	newPerson -> spinSpeed = newPerson -> thisType -> spinSpeed;
	newPerson -> r = 0;
	newPerson -> g = 0;
	newPerson -> b = 0;
	newPerson -> colourmix = 0;
	newPerson -> transparency = 0;
	newPerson -> myPersona = p;

	setFrames (* newPerson, ANI_STAND);

	// HEIGHT (BASED ON 1st FRAME OF 1st ANIMATION... INC. SPECIAL CASES)
	int fNumSigned = p -> animation[0] -> frames[0].frameNum;
	int fNum = abs (fNumSigned);
	if (fNum >= p -> animation[0] -> theSprites -> bank.total) {
		if (fNumSigned < 0) {
			newPerson -> height = 5;
		} else {
			newPerson -> height = p -> animation[0] -> theSprites -> bank.sprites[0].yhot + 5;
		}
	} else {
		newPerson -> height = p -> animation[0] -> theSprites -> bank.sprites[fNum].yhot + 5;
	}

	// NOW ADD IT IN THE RIGHT PLACE
	onScreenPerson * * changethat = & allPeople;

	while (((* changethat) != NULL) && ((* changethat) -> y < y))
		changethat = & ((* changethat) -> next);

	newPerson -> next = (* changethat);
	(* changethat) = newPerson;

	return (bool) (newPerson -> thisType != NULL);
}
示例#15
0
personaAnimation * makeNullAnim () {
	personaAnimation * newAnim	= new personaAnimation;
	if (! checkNew (newAnim)) return NULL;


	newAnim -> theSprites		= NULL;
	newAnim -> numFrames		= 0;
	newAnim -> frames			= NULL;
	return newAnim;
}
示例#16
0
bool FloorManager::init() {
	_currentFloor = new Floor;
	if (!checkNew(_currentFloor))
		return false;
	_currentFloor->numPolygons = 0;
	_currentFloor->polygon = nullptr;
	_currentFloor->vertex = nullptr;
	_currentFloor->matrix = nullptr;
	return true;
}
示例#17
0
char *createCString(const Common::String &s) {
	uint n = s.size() + 1;
	char *res = new char[n];
	if (!checkNew(res)) {
		fatal("createCString : Unable to copy String");
		return NULL;
	}
	memcpy(res, s.c_str(), n);
	return res;
}
示例#18
0
bool reserveSpritePal (spritePalette & sP, int n) {
	if (sP.pal) {
		delete  [] sP.pal;
		delete  [] sP.r;
		delete  [] sP.g;
		delete  [] sP.b;
	}

	sP.pal = new unsigned short int [n];
	if (! checkNew (sP.pal)) return false;

	sP.r = new unsigned char [n];
	if (! checkNew (sP.r)) return false;
	sP.g = new unsigned char [n];
	if (! checkNew (sP.g)) return false;
	sP.b = new unsigned char [n];
	if (! checkNew (sP.b)) return false;
	sP.total = n;
	return (bool) (sP.pal != NULL) && (sP.r != NULL) && (sP.g != NULL) && (sP.b != NULL);
}
示例#19
0
bool addVarToStack(const Variable &va, VariableStack *&thisStack) {
	VariableStack *newStack = new VariableStack;
	if (!checkNew(newStack))
		return false;

	if (!copyMain(va, newStack->thisVar))
		return false;
	newStack->next = thisStack;
	thisStack = newStack;
	//debugC(2, kSludgeDebugStackMachine, "Variable %s was added to stack", getTextFromAnyVar(va));
	return true;
}
示例#20
0
bool addVarToStackQuick (variable & va, variableStack * & thisStack) {
	variableStack * newStack = new variableStack;
	if (! checkNew (newStack)) return false;

//	if (! copyMain (va, newStack -> thisVar)) return false;

	memcpy (& (newStack -> thisVar), & va, sizeof (variable));
	va.varType = SVT_NULL;

	newStack -> next = thisStack;
	thisStack = newStack;
	return true;
}
示例#21
0
bool loadVariable(Variable *to, Common::SeekableReadStream *stream) {
	to->varType = (VariableType)stream->readByte();
	switch (to->varType) {
		case SVT_INT:
		case SVT_FUNC:
		case SVT_BUILT:
		case SVT_FILE:
		case SVT_OBJTYPE:
			to->varData.intValue = stream->readUint32LE();
			return true;

		case SVT_STRING:
			to->varData.theString = createCString(readString(stream));
			return true;

		case SVT_STACK:
			to->varData.theStack = loadStackRef(stream);
			return true;

		case SVT_COSTUME:
			to->varData.costumeHandler = new Persona;
			if (!checkNew(to->varData.costumeHandler))
				return false;
			loadCostume(to->varData.costumeHandler, stream);
			return true;

		case SVT_ANIM:
			to->varData.animHandler = new PersonaAnimation ;
			if (!checkNew(to->varData.animHandler))
				return false;
			loadAnim(to->varData.animHandler, stream);
			return true;

		default:
			break;
	}
	return true;
}
// new groups
void KNGroupDialog::slotUser2()
{
  QDate lastDate = a_ccount->lastNewFetch();
  KDialog *dlg = new KDialog( this );
  dlg->setCaption( i18n("New Groups") );
  dlg->setButtons( Ok | Cancel );

  QGroupBox *btnGrp = new QGroupBox( i18n("Check for New Groups"), dlg );
  dlg->setMainWidget(btnGrp);
  QGridLayout *topL = new QGridLayout( btnGrp );

  QRadioButton *takeLast = new QRadioButton( i18n("Created since last check:"), btnGrp );
  topL->addWidget(takeLast, 0, 0, 1, 2 );

  QLabel *l = new QLabel(KGlobal::locale()->formatDate(lastDate, KLocale::LongDate),btnGrp);
  topL->addWidget(l, 1, 1, Qt::AlignLeft);

  connect(takeLast, SIGNAL(toggled(bool)), l, SLOT(setEnabled(bool)));

  QRadioButton *takeCustom = new QRadioButton( i18n("Created since this date:"), btnGrp );
  topL->addWidget(takeCustom, 2, 0, 1, 2 );

  dateSel = new KDatePicker( lastDate, btnGrp );
  dateSel->setMinimumSize(dateSel->sizeHint());
  topL->addWidget(dateSel, 3, 1, Qt::AlignLeft);

  connect(takeCustom, SIGNAL(toggled(bool)), this, SLOT(slotDatePickerEnabled(bool)));

  takeLast->setChecked(true);
  dateSel->setEnabled(false);

  topL->addItem( new QSpacerItem(30, 0 ), 0, 0 );

  if (dlg->exec()) {
    if (takeCustom->isChecked())
      lastDate = dateSel->date();
    a_ccount->setLastNewFetch(QDate::currentDate());
    leftLabel->setText(i18n("Checking for new groups..."));
    enableButton(User1,false);
    enableButton(User2,false);
    filterEdit->clear();
    subCB->setChecked(false);
    newCB->setChecked(true);
    emit(checkNew(a_ccount,lastDate));
    incrementalFilter=false;
    slotRefilter();
  }

  delete dlg;
}
示例#23
0
bool copyStack (const variable & from, variable & to) {
	to.varType = SVT_STACK;
	to.varData.theStack = new stackHandler;
	if (! checkNew (to.varData.theStack)) return false;
	to.varData.theStack -> first = NULL;
	to.varData.theStack -> last = NULL;
	to.varData.theStack -> timesUsed = 1;
	variableStack * a = from.varData.theStack -> first;

#if DEBUG_STACKINESS
	{
		char * str = getTextFromAnyVar(from);
		stackDebug((stackfp, "in copyStack, copying %s\n", str));
		delete[] str;
	}
#endif

	while (a) {
		addVarToStack (a -> thisVar, to.varData.theStack -> first);
		if (to.varData.theStack -> last == NULL)
		{
#if DEBUG_STACKINESS
			stackDebug((stackfp, "LAST"));
#endif
			to.varData.theStack -> last = to.varData.theStack -> first;
		}

#if DEBUG_STACKINESS
		{
			char * str = getTextFromAnyVar(a->thisVar);
			stackDebug((stackfp, "\ta->thisVar = %s (%p)\n", str, to.varData.theStack->first));
			delete[] str;
		}
#endif

		a = a -> next;
	}

#if DEBUG_STACKINESS
	{
		char * str = getTextFromAnyVar(to);
		stackDebug((stackfp, "finished copy, got %s\n", str));
		delete[] str;
		stackDebug((stackfp, "first = %p\n", to.varData.theStack->first));
		stackDebug((stackfp, "last = %p\n", to.varData.theStack->last));
	}
#endif
	return true;
}
示例#24
0
result_t XmlNodeList::appendChild(XmlNode_base *newChild, obj_ptr<XmlNode_base> &retVal)
{
    XmlNodeImpl *pNew = checkChild(newChild);
    if (!pNew)
        return CHECK_ERROR(CALL_E_INVALIDARG);

    if (!checkNew(pNew))
        return CHECK_ERROR(Runtime::setError("The new child element contains the parent."));

    pNew->setParent(m_this, (int32_t)m_childs.size());
    m_childs.push_back(pNew);

    retVal = newChild;
    return 0;
}
示例#25
0
bool addVarToStackQuick(Variable &va, VariableStack *&thisStack) {
	VariableStack *newStack = new VariableStack;
	if (!checkNew(newStack))
		return false;

//	if (! copyMain (va, newStack -> thisVar)) return false;

	memcpy(&(newStack->thisVar), &va, sizeof(Variable));
	va.varType = SVT_NULL;

	newStack->next = thisStack;
	thisStack = newStack;
	//debugC(2, kSludgeDebugStackMachine, "Variable %s was added to stack quick", getTextFromAnyVar(va));
	return true;
}
示例#26
0
bool addScreenRegion (int x1, int y1, int x2, int y2, int sX, int sY, int di, int objectNum) {
	screenRegion * newRegion = new screenRegion;
	if (! checkNew (newRegion)) return false;
	newRegion -> di = di;
	newRegion -> x1 = x1;
	newRegion -> y1 = y1;
	newRegion -> x2 = x2;
	newRegion -> y2 = y2;
	newRegion -> sX = sX;
	newRegion -> sY = sY;
	newRegion -> thisType = loadObjectType (objectNum);
	newRegion -> next = allScreenRegions;
	allScreenRegions = newRegion;
	return (bool) (newRegion -> thisType != NULL);
}
示例#27
0
bool loadFont (int filenum, const char * charOrder, int h) {
	int a=0;
	uint32_t c;

	delete [] fontOrderString;
	fontOrderString = copyString(charOrder);
		
	forgetSpriteBank (theFont);

	loadedFontNum = filenum;
	

	fontTableSize = 0;
	while (charOrder[a]) {
        c = u8_nextchar(charOrder, &a);
		if (c > fontTableSize) fontTableSize = c;
	}
	fontTableSize++;

	delete [] fontTable;
	fontTable = new uint32_t [fontTableSize];
	if (! checkNew (fontTable)) return false;	

	for (a = 0; a < fontTableSize; a ++) {
		fontTable[a] = 0;
	}
	a=0;
	int i=0;
	while (charOrder[a]) {
        c = u8_nextchar(charOrder, &a);
		fontTable[c] = i;
		i++;
	}

	if (! loadSpriteBank (filenum, theFont, true)) {
		fatal ("Can't load font");
		return false;
	}

	numFontColours = theFont.myPalette.total;
	fontHeight = h;
	return true;
}
示例#28
0
bool copyStack(const Variable &from, Variable &to) {
	to.varType = SVT_STACK;
	to.varData.theStack = new StackHandler;
	if (!checkNew(to.varData.theStack))
		return false;
	to.varData.theStack->first = NULL;
	to.varData.theStack->last = NULL;
	to.varData.theStack->timesUsed = 1;
	VariableStack *a = from.varData.theStack->first;

	while (a) {
		addVarToStack(a->thisVar, to.varData.theStack->first);
		if (to.varData.theStack->last == NULL) {
			to.varData.theStack->last = to.varData.theStack->first;
		}
		a = a->next;
	}

	return true;
}
示例#29
0
VariableStack *loadStack(Common::SeekableReadStream *stream, VariableStack **last) {
	int elements = stream->readUint16BE();
	int a;
	VariableStack *first = NULL;
	VariableStack **changeMe = &first;

	for (a = 0; a < elements; a++) {
		VariableStack *nS = new VariableStack;
		if (!checkNew(nS))
			return NULL;
		loadVariable(&(nS->thisVar), stream);
		if (last && a == elements - 1) {
			*last = nS;
		}
		nS->next = NULL;
		(*changeMe) = nS;
		changeMe = &(nS->next);
	}

	return first;
}
示例#30
0
bool reserveBackdrop () {
	cameraX = 0;
	cameraY = 0;
	input.mouseX = (int)((float)input.mouseX * cameraZoom);
	input.mouseY = (int)((float)input.mouseY * cameraZoom);
	cameraZoom = 1.0;
	input.mouseX = (int)((float)input.mouseX / cameraZoom);
	input.mouseY = (int)((float)input.mouseY / cameraZoom);
	setPixelCoords(false);
	int picWidth = sceneWidth;
	int picHeight = sceneHeight;

	glPixelStorei (GL_UNPACK_ALIGNMENT, 1);

	if (backdropTexture) delete backdropTexture;
	if (! NPOT_textures) {
		picWidth = getNextPOT(sceneWidth);
		picHeight = getNextPOT(sceneHeight);
		backdropTexW = ((double)sceneWidth) / picWidth;
		backdropTexH = ((double)sceneHeight) / picHeight;
	}
	backdropTexture = new GLubyte [picWidth*picHeight*4];
	if (! checkNew (backdropTexture)) return false;

	if (! backdropTextureName) glGenTextures (1, &backdropTextureName);
	glBindTexture (GL_TEXTURE_2D, backdropTextureName);
	glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
	glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
	if (gameSettings.antiAlias < 0) {
		glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
		glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	} else {
		glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
		glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
	}

	texImage2D (GL_TEXTURE_2D, 0, GL_RGBA, picWidth, picHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, backdropTexture, backdropTextureName);

	return true;
}