project_files/frontlib/ipc/ipcprotocol.c
changeset 7320 e704706008d4
parent 7316 f7b49b2c5d84
child 7482 d70a5b0d1190
equal deleted inserted replaced
7318:a446eafcddeb 7320:e704706008d4
   129 	}
   129 	}
   130 	free(copy);
   130 	free(copy);
   131 	return result;
   131 	return result;
   132 }
   132 }
   133 
   133 
   134 static uint32_t buildModFlags(const flib_cfg *scheme) {
   134 static uint32_t buildModFlags(const flib_scheme *scheme) {
   135 	uint32_t result = 0;
   135 	uint32_t result = 0;
   136 	for(int i=0; i<scheme->meta->modCount; i++) {
   136 	for(int i=0; i<scheme->meta->modCount; i++) {
   137 		if(scheme->mods[i]) {
   137 		if(scheme->mods[i]) {
   138 			int bitmaskIndex = scheme->meta->mods[i].bitmaskIndex;
   138 			int bitmaskIndex = scheme->meta->mods[i].bitmaskIndex;
   139 			result |= (UINT32_C(1) << bitmaskIndex);
   139 			result |= (UINT32_C(1) << bitmaskIndex);
   140 		}
   140 		}
   141 	}
   141 	}
   142 	return result;
   142 	return result;
   143 }
   143 }
   144 
   144 
   145 int flib_ipc_append_gamescheme(flib_vector *vec, const flib_cfg *scheme) {
   145 int flib_ipc_append_gamescheme(flib_vector *vec, const flib_scheme *scheme) {
   146 	int result = -1;
   146 	int result = -1;
   147 	flib_vector *tempvector = flib_vector_create();
   147 	flib_vector *tempvector = flib_vector_create();
   148 	if(!log_badargs_if2(vec==NULL, scheme==NULL) && tempvector) {
   148 	if(!log_badargs_if2(vec==NULL, scheme==NULL) && tempvector) {
   149 		const flib_cfg_meta *meta = scheme->meta;
   149 		const flib_metascheme *meta = scheme->meta;
   150 		bool error = false;
   150 		bool error = false;
   151 		error |= flib_ipc_append_message(tempvector, "e$gmflags %"PRIu32, buildModFlags(scheme));
   151 		error |= flib_ipc_append_message(tempvector, "e$gmflags %"PRIu32, buildModFlags(scheme));
   152 		for(int i=0; i<meta->settingCount; i++) {
   152 		for(int i=0; i<meta->settingCount; i++) {
   153 			if(meta->settings[i].engineCommand) {
   153 			if(meta->settings[i].engineCommand) {
   154 				int value = scheme->settings[i];
   154 				int value = scheme->settings[i];
   261 		if(setup->script) {
   261 		if(setup->script) {
   262 			error |= flib_ipc_append_script(tempvector, setup->script);
   262 			error |= flib_ipc_append_script(tempvector, setup->script);
   263 		}
   263 		}
   264 		if(setup->gamescheme) {
   264 		if(setup->gamescheme) {
   265 			error |= flib_ipc_append_gamescheme(tempvector, setup->gamescheme);
   265 			error |= flib_ipc_append_gamescheme(tempvector, setup->gamescheme);
   266 			sharedAmmo = flib_cfg_get_mod(setup->gamescheme, "sharedammo");
   266 			sharedAmmo = flib_scheme_get_mod(setup->gamescheme, "sharedammo");
   267 			// Shared ammo has priority over per-hog ammo
   267 			// Shared ammo has priority over per-hog ammo
   268 			perHogAmmo = !sharedAmmo && flib_cfg_get_mod(setup->gamescheme, "perhogammo");
   268 			perHogAmmo = !sharedAmmo && flib_scheme_get_mod(setup->gamescheme, "perhogammo");
   269 		}
   269 		}
   270 		if(setup->teamlist->teams && setup->teamlist->teamCount>0) {
   270 		if(setup->teamlist->teams && setup->teamlist->teamCount>0) {
   271 			int *clanColors = flib_calloc(setup->teamlist->teamCount, sizeof(int));
   271 			int *clanColors = flib_calloc(setup->teamlist->teamCount, sizeof(int));
   272 			if(!clanColors) {
   272 			if(!clanColors) {
   273 				error = true;
   273 				error = true;