Пример #1
0
std::vector<bool>::reference Game_Switches_Class::operator[](int switch_id) {
	if (!IsValid(switch_id)) {
		if (switch_id > 0 && switch_id <= PLAYER_VAR_LIMIT) {
			Output::Debug("Resizing switch array to %d elements.", switch_id);
			switches().resize(switch_id);
			Main_Data::game_data.system.switches_size = switches().size();
		} else {
			Output::Debug("Switch index %d is invalid.", switch_id);
			dummy.resize(1);
			return dummy[0];
		}
	}

	return switches()[switch_id - 1];
}
Пример #2
0
		void recv_can()
		{
			Can::Packet pkt(0);
			uint32_t id;
			this->common_can_in.rx(pkt,id);

			switch (id)
			{
				case Can::Addr::dc::switches::_id: {
					Can::Addr::dc::switches switches(pkt);
					this->state.dc_run = switches.frame().switchFlags & (1<<5);
					this->state.dc_start = switches.frame().switchFlags & (1<<5);
					break;
				}
				default: {
				}
			}

			// If state.mode_timeout_clock isn't updated fast enough, turn OFF.
			if (this->dc_can_timeout.has_expired())
			{
				this->dc_can_timeout.kill();
				this->state.dc_run = false;
				this->state.dc_start = false;
			}
		}
Пример #3
0
int main(int argc, const char *argv[]) {
  simple_loops();
  conditionals();
  early_exits();
  jumps();
  switches();
  big_switch();
  boolean_operators();
  boolop_loops();
  do_fallthrough();
  static_func();
  return 0;
}
Пример #4
0
int jvs_device::handle_message(const UINT8 *send_buffer, UINT32 send_size, UINT8 *&recv_buffer)
{
	UINT32 old_reset_counter = jvs_reset_counter;
	jvs_reset_counter = 0;

	switch(send_buffer[0]) {
	case 0xf0:
		if(send_size < 2 || send_buffer[1] != 0xd9)
			return 0;

		// Reset, must be sent twice
		jvs_reset_counter = old_reset_counter+1;
		if(jvs_reset_counter == 2)
			device_reset();
		return 2;

	case 0x10: {
		const char *id = device_id();
		int len = strlen(id)+1;
		*recv_buffer++ = 0x01;
		memcpy(recv_buffer, id, len);
		recv_buffer += len;
		return 1;
	}

	case 0x11:
		*recv_buffer++ = 0x01;
		*recv_buffer++ = command_format_version();
		return 1;

	case 0x12:
		*recv_buffer++ = 0x01;
		*recv_buffer++ = jvs_standard_version();
		return 1;

	case 0x13:
		*recv_buffer++ = 0x01;
		*recv_buffer++ = comm_method_version();
		return 1;

	case 0x14:
		*recv_buffer++ = 0x01;
		function_list(recv_buffer);
		*recv_buffer++ = 0x00;
		return 1;

	case 0x20:
		if(send_size < 3)
			return 0;
		*recv_buffer++ = 0x01;
		return switches(recv_buffer, send_buffer[1], send_buffer[2]) ? 3 : 0;

	case 0x21:
		if(send_size < 2)
			return 0;
		*recv_buffer++ = 0x01;
		return coin_counters(recv_buffer, send_buffer[1]) ? 2 : 0;

	case 0x22:
		if(send_size < 2)
			return 0;
		*recv_buffer++ = 0x01;
		return analogs(recv_buffer, send_buffer[1]) ? 2 : 0;

	case 0x30:
		if(send_size < 4)
			return 0;
		*recv_buffer++ = 0x01;
		return coin_add(send_buffer[1], -((send_buffer[2] << 8) | send_buffer[3])) ? 4 : 0;

	case 0x31:
		if(send_size < 4)
			return 0;
		*recv_buffer++ = 0x01;
		return coin_add(send_buffer[1],  ((send_buffer[2] << 8) | send_buffer[3])) ? 4 : 0;

	case 0x32:
		if(send_size < 2 || send_size < 2+send_buffer[1])
			return 0;
		*recv_buffer++ = 0x01;
		return swoutputs(send_buffer[1], send_buffer+2) ? 2+send_buffer[1] : 0;

	case 0x38:
		if(send_size < 3)
			return 0;
		*recv_buffer++ = 0x01;
		return swoutputs(send_buffer[1], send_buffer[2]) ? 3 : 0;

	default:
		logerror("JVSDEV: unhandled command %02x\n", send_buffer[0]);
		return 0;
	}

	return -1;
}
Пример #5
0
void Game_Switches_Class::Reset() {
	switches().assign(Data::switches.size(), false);
}
Пример #6
0
int Game_Switches_Class::GetSize() const {
	return (int)switches().size();
}
Пример #7
0
bool Game_Switches_Class::IsValid(int switch_id) const {
	return (switch_id > 0 && switch_id <= (int)switches().size());
}
Пример #8
0
/*======================================================================*/
void args(int argc, char * argv[])
{
  char *programName;
  char *exePoint;

#ifdef ARGSDISPLAY
  int i;

  MessageBox(NULL, "Hello!", "Windows Arun interpreter", MB_OK);
  MessageBox(NULL, GetCommandLine(), "", MB_OK);
  for (i = 0; i < argc; i++) {
    char buf[199];
    sprintf(buf, "arg %d :\"%s\"", i, argv[i]);
    MessageBox(NULL, buf, "Alan V3 compiler", MB_OK);
  }
#endif

#ifdef HAVE_WINGLK
  argv[0] = GetCommandLine();
#endif
  if ((programName = strrchr(argv[0], '\\')) == NULL
      && (programName = strrchr(argv[0], '/')) == NULL
      && (programName = strrchr(argv[0], ':')) == NULL)
    programName = strdup(argv[0]);
  else
    programName = strdup(&programName[1]);

  if (strlen(programName) > 4 && (((exePoint = strstr(programName, ".EXE")) != NULL) || (exePoint = strstr(programName, ".exe")) != NULL))
    *exePoint = '\0';

  /* Now look at the switches and arguments */
  switches(argc, argv);

#ifdef ARGSDISPLAY
  {
    char buf[100];
    sprintf(buf, "programName = '%s'\nadventureFileName = '%s'", programName, adventureFileName);
    MessageBox(NULL, buf, "Alan V3 compiler", MB_OK);
  }
#endif

  // TODO This is the same as in unixargs.c
  if (adventureFileName == NULL) {
    /* No game given, try program name */
    if (differentInterpreterName(programName)) {
      // TODO break out as a function
      FILE *adventureFile;
      adventureFileName = duplicate(programName,
				    strlen(programName)
				    +strlen(ACODEEXTENSION)+1);
      strcat(adventureFileName, ACODEEXTENSION);
      // TODO break out as utils::fileExists()
      if ((adventureFile = fopen(adventureFileName, "r")) == NULL) {
	free(adventureFileName);
	adventureFileName = NULL;
      } else
	fclose(adventureFile);
    }
  }
  adventureName = gameName(adventureFileName);
  free(programName);
}
Пример #9
0
/* FIXME! buffer overflows? */
static int handle_choice(const char *askbuf)
{
	char lesbabuf[30];
	struct userbase muser = user;
	int leps;
		
	if (!(strcasecmp(askbuf, "1"))) {
		for (;;) {
			if (!isaccess(SECB_REALNAME, access2))
				break;
			DDPut(sd[eu1str]);
			strlcpy(lesbabuf, user.user_realname, sizeof lesbabuf);
			if (!(Prompt(lesbabuf, 25, 0)))
				return 1;
			removespaces(lesbabuf);
			if (strcasecmp(lesbabuf, user.user_realname)) {
				leps = findusername(lesbabuf);
				if (leps == user.user_account_id || leps == -1) {
					if (lesbabuf[0])
						strlcpy(user.user_realname, lesbabuf, sizeof user.user_realname);
				} else {
					DDPut(sd[newalreadystr]);
					continue;
				}
			}
			break;
		}
	} else if (!(strcasecmp(askbuf, "2"))) {
		for (;;) {
			if (!isaccess(SECB_HANDLE, access2))
				break;
			DDPut(sd[eu2str]);
			strlcpy(lesbabuf, user.user_handle, sizeof lesbabuf);
			if (!(Prompt(lesbabuf, 25, 0)))
				return 1;
			removespaces(lesbabuf);
			if (strcasecmp(lesbabuf, user.user_handle)) {
				leps = findusername(lesbabuf);
				if (leps == user.user_account_id || leps == -1) {
					if (lesbabuf[0])
						strlcpy(user.user_handle, lesbabuf, sizeof user.user_handle);
				} else {
					DDPut(sd[newalreadystr]);
					continue;
				}
			}
			break;
		}
	} else if (!(strcasecmp(askbuf, "3"))) {
		DDPut(sd[eu3str]);
		if (!(Prompt(user.user_organization, 25, 0)))
			return 1;
	} else if (!(strcasecmp(askbuf, "4"))) {
		DDPut(sd[eu4str]);
		if (!(Prompt(user.user_zipcity, 20, 0)))
			return 1;
	} else if (!(strcasecmp(askbuf, "5"))) {
		DDPut(sd[eu5str]);
		if (!(Prompt(user.user_voicephone, 20, 0)))
			return 1;
	} else if (!(strcasecmp(askbuf, "6"))) {
		MD_CTX context;
		char verifypw[32];
		DDPut(sd[eu6str]);
		lesbabuf[0] = 0;
		if (!(Prompt(lesbabuf, 15, PROMPT_SECRET)))
			return 1;
		if (lesbabuf[0] == 0)
			return 0;
		*verifypw = 0;
		DDPut(sd[euverifypwstr]);
		if (!(Prompt(verifypw, 15, PROMPT_SECRET)))
			return 1;
		if (strcasecmp(lesbabuf, verifypw)) {
			DDPut(sd[eunomatchstr]);
			return 0;
		}
		strupr(lesbabuf);
		MDInit(&context);
		MDUpdate(&context, (unsigned char *) lesbabuf, 
			strlen(lesbabuf));
		MDFinal(user.user_password, &context);
	} else if (!strcasecmp(askbuf, "7")) {
		for (;;) {
			int fallos;
			
			DDPut(sd[eu7str]);
			lesbabuf[0] = 0;
			if (!(Prompt(lesbabuf, 3, 0)))
				return 1;
			if (lesbabuf[0] == 't' || lesbabuf[0] == 'T') {
				testscreenl();
				continue;
			}
			fallos = atoi(lesbabuf);
			if (fallos < 10) {
				DDPut(sd[newminslstr]);
				continue;
			}
			user.user_screenlength = fallos;
			break;
		}
	} else if (!(strcasecmp(askbuf, "8"))) {
		struct DayDream_Protocol *tp;

		TypeFile("protocols", TYPE_MAKE | TYPE_WARN);
		DDPut(sd[eu8str]);
		*lesbabuf = 0;
		if (user.user_protocol) {
			*lesbabuf = user.user_protocol;
			lesbabuf[1] = 0;
		}
		if (!(Prompt(lesbabuf, 3, 0)))
			return 1;
		*lesbabuf = toupper(*lesbabuf);
		if (!*lesbabuf)
			return 0;
		tp = protocols;
		for (;;) {
			if (tp->PROTOCOL_ID == 0)
				return 0;
			if (tp->PROTOCOL_ID == *lesbabuf) {
				protocol = tp;
				user.user_protocol = *lesbabuf;
				return 0;
			}
			tp++;
		}
	} else if (!(strcasecmp(askbuf, "9"))) {
		DDPut(sd[eu9str]);
		if (!(Prompt(user.user_signature, 44, 0)))
			return 1;
	} else if (!(strcasecmp(askbuf, "10"))) {
		DDPut(sd[eu10str]);
		if (!(Prompt(user.user_computermodel, 20, 0)))
			return 1;
	} else if (!(strcasecmp(askbuf, "11"))) {
		DDPut(sd[eu11str]);
		snprintf(lesbabuf, sizeof lesbabuf, "%d", user.user_flines);
		if (!(Prompt(lesbabuf, 3, 0)))
			return 1;
		user.user_flines = atoi(lesbabuf);
        } else if (!(strcasecmp(askbuf, "12"))) {
		rundoor("doors/autosig %N", 0);
		return 1;
	} else if (!(strcasecmp(askbuf, "a"))) {
		DDPut(sd[euabortedstr]);
		user = muser;
		return 1;
	} else if (!(strcasecmp(askbuf, "v"))) {
		TypeFile("edituser", TYPE_MAKE | TYPE_WARN);
	} else if (!(strcasecmp(askbuf, "s"))) {
		switches();
	} else if ((!(strcasecmp(askbuf, "c")) || (askbuf[0] == 0))) {
		DDPut(sd[eusavedstr]);
		saveuserbase(&user);
		return 1;
	}
	return 0;
}