Beispiel #1
0
void *sd_add(strdict *sd, const char *key, void *value)
{
   strdictel *kv;
   void *oldValue;

   oldValue = sd_removeKey(sd, key);
   if (value != NULL)
   {
      if (sd->count == sd->capacity) {
         kv = findNull(sd);			/* try to recycle space */
         if (kv == NULL) {
            sd_setCapacity(sd, sd->capacity * 2);	/* make more space */
            if (sd->count == sd->capacity)
            {
               WOLog(WO_ERR, "sd_add(): could not add element (%s = %s) due to allocation failure", key, value);
               return oldValue;
            } else {
               kv = sd->head + sd->count;
               sd->count++;
            }
         }
      } else {
         kv = sd->head + sd->count;
         sd->count++;
      }
      kv->key = WOSTRDUP(key);
      kv->value = value;
   }
   return oldValue;
}
Beispiel #2
0
void Scripts::doCmdPrint_v1(Common::String msg) {
	_vm->_screen->_printOrg = Common::Point(20, 42);
	_vm->_screen->_printStart = Common::Point(20, 32);
	_vm->_bubbleBox->placeBubble(msg);
	_vm->_events->waitKeyMouse();
	_vm->_events->hideCursor();
	_vm->_screen->restoreBlock();
	_vm->_events->showCursor();
	findNull();
}
Beispiel #3
0
void Scripts::cmdCharSpeak() {
	_vm->_screen->_printOrg = _charsOrg;
	_vm->_screen->_printStart = _charsOrg;

	byte v;
	Common::String tmpStr = "";
	while ((v = _data->readByte()) != 0)
		tmpStr += (char)v;

	_vm->_bubbleBox->placeBubble(tmpStr);
	findNull();
}
Beispiel #4
0
void Scripts::cmdTexSpeak() {
	_vm->_screen->_printOrg = _texsOrg;
	_vm->_screen->_printStart = _texsOrg;
	_vm->_screen->_maxChars = (_vm->getGameID() == GType_MartianMemorandum) ? 23 : 20;

	byte v;
	Common::String tmpStr = "";
	while ((v = _data->readByte()) != 0)
		tmpStr += (char)v;

	if (_vm->getGameID() == GType_MartianMemorandum)
		_vm->_bubbleBox->_bubbleDisplStr = Common::String("TEX");
	else
		_vm->_bubbleBox->_bubbleDisplStr = Common::String("JASON");

	_vm->_bubbleBox->placeBubble1(tmpStr);
	findNull();
}
Beispiel #5
0
void Scripts::cmdTexChoice() {
	// MM is defining 2 times the last range in the original.
	static const int BTN_RANGES_v1[BTN_COUNT][2] = {
		{ 0, 60 }, { 64, 124 }, { 129, 192 }, { 194, 227 }, { 233, 292 }, { 297, 319 }
	};

	static const int BTN_RANGES_v2[BTN_COUNT][2] = {
		{ 0, 76 }, { 77, 154 }, { 155, 232 }, { 233, 276 }, { 0, 0 }, { 277, 319 }
	};


	_vm->_oldRects.clear();
	_choiceStart = _data->pos() - 1;
	_vm->_fonts._charSet._lo = 1;
	_vm->_fonts._charSet._hi = 8;
	_vm->_fonts._charFor._hi = 255;

	if (_vm->getGameID() == GType_MartianMemorandum) {
		_vm->_fonts._charFor._lo = 247;
		_vm->_screen->_maxChars = 23;
	} else {
		_vm->_fonts._charFor._lo = 55;
		_vm->_screen->_maxChars = 20;
	}

	_vm->_screen->_printOrg = _texsOrg;
	_vm->_screen->_printStart = _texsOrg;

	_vm->_bubbleBox->clearBubbles();
	_vm->_bubbleBox->_bubbleDisplStr = Common::String("RESPONSE 1");

	byte v;
	Common::String tmpStr = "";
	while ((v = _data->readByte()) != 0)
		tmpStr += (char)v;

	_vm->_bubbleBox->calcBubble(tmpStr);
	_vm->_bubbleBox->printBubble(tmpStr);

	Common::Array<Common::Rect> responseCoords;
	responseCoords.push_back(_vm->_bubbleBox->_bounds);
	_vm->_screen->_printOrg.y = _vm->_bubbleBox->_bounds.bottom + ((_vm->getGameID() == GType_MartianMemorandum) ? 20 : 11);

	findNull();

	tmpStr.clear();
	while ((v = _data->readByte()) != 0)
		tmpStr += (char)v;

	if (tmpStr.size() != 0) {
		_vm->_bubbleBox->_bubbleDisplStr = Common::String("RESPONSE 2");
		_vm->_bubbleBox->calcBubble(tmpStr);
		_vm->_bubbleBox->printBubble(tmpStr);
		responseCoords.push_back(_vm->_bubbleBox->_bounds);
		_vm->_screen->_printOrg.y = _vm->_bubbleBox->_bounds.bottom + ((_vm->getGameID() == GType_MartianMemorandum) ? 20 : 11);
	}

	findNull();

	bool choice3Fl = false;
	tmpStr.clear();
	while ((v = _data->readByte()) != 0)
		tmpStr += (char)v;

	if (tmpStr.size() != 0) {
		_vm->_bubbleBox->_bubbleDisplStr = Common::String("RESPONSE 3");
		_vm->_bubbleBox->calcBubble(tmpStr);
		_vm->_bubbleBox->printBubble(tmpStr);
		responseCoords.push_back(_vm->_bubbleBox->_bounds);
		_vm->_screen->_printOrg.y = _vm->_bubbleBox->_bounds.bottom + ((_vm->getGameID() == GType_MartianMemorandum) ? 20 : 11);
	}

	findNull();

	int choice = -1;
	do {
		_vm->_events->pollEvents();
		if (_vm->shouldQuit())
			return;

		charLoop();

		_vm->_bubbleBox->_bubbleDisplStr = _vm->_bubbleBox->_bubbleTitle;
		if (_vm->_events->_leftButton) {
			if (_vm->_events->_mouseRow >= ((_vm->getGameID() == GType_MartianMemorandum) ? 23 : 22)) {
				_vm->_events->debounceLeft();
				int x = _vm->_events->_mousePos.x;
				for (int i = 0; i < BTN_COUNT; i++) {
					if (((_vm->getGameID() == GType_MartianMemorandum) && (x >= BTN_RANGES_v1[i][0]) && (x < BTN_RANGES_v1[i][1]))
					||  ((_vm->getGameID() == GType_Amazon) && (x >= BTN_RANGES_v2[i][0]) && (x < BTN_RANGES_v2[i][1]))) {

						choice = i;
						break;
					}
				}
			} else {
				_vm->_events->debounceLeft();
				choice = _vm->_events->checkMouseBox1(responseCoords);
			}
		}
	} while ((choice == -1) || ((choice == 2) && choice3Fl));

	_choice = choice + 1;
	_vm->_bubbleBox->clearBubbles();
}
Beispiel #6
0
void Scripts::cmdPrintWatch() {
	printWatch();
	findNull();
}