project_files/frontlib/model/weapon.c
changeset 7316 f7b49b2c5d84
parent 7314 6171f0bad318
child 7320 e704706008d4
--- a/project_files/frontlib/model/weapon.c	Wed Jun 27 22:52:19 2012 +0200
+++ b/project_files/frontlib/model/weapon.c	Thu Jul 05 00:33:24 2012 +0200
@@ -59,9 +59,7 @@
 
 flib_weaponset *flib_weaponset_create(const char *name) {
 	flib_weaponset *result = NULL;
-	if(!name) {
-		flib_log_e("null parameter in flib_weaponset_create_str");
-	} else {
+	if(!log_badargs_if(name==NULL)) {
 		flib_weaponset *newSet = flib_weaponset_retain(flib_calloc(1, sizeof(flib_weaponset)));
 		if(newSet) {
 			newSet->name = flib_strdupnull(name);
@@ -119,9 +117,7 @@
 
 flib_weaponset *flib_weaponset_from_ammostring(const char *name, const char *ammostring) {
 	flib_weaponset *result = NULL;
-	if(!name || !ammostring) {
-		flib_log_e("null parameter in flib_weaponset_from_ammostring");
-	} else {
+	if(!log_badargs_if2(name==NULL, ammostring==NULL)) {
 		result = flib_weaponset_create(name);
 		if(result) {
 			int fieldlen = strlen(ammostring)/4;
@@ -164,9 +160,7 @@
 
 flib_weaponsetlist *flib_weaponsetlist_from_ini(const char *filename) {
 	flib_weaponsetlist *result = NULL;
-	if(!filename) {
-		flib_log_e("null parameter in flib_weaponsetlist_from_ini");
-	} else {
+	if(!log_badargs_if(filename==NULL)) {
 		flib_ini *ini = flib_ini_load(filename);
 		if(!ini) {
 			flib_log_e("Missing file %s.", filename);
@@ -189,7 +183,6 @@
 static bool needsEscape(char c) {
 	return !((c>='0' && c<='9') || (c>='a' && c <='z'));
 }
-
 
 static int writeWeaponsetToIni(flib_ini *ini, flib_weaponset *set) {
 	int result = -1;
@@ -209,9 +202,7 @@
 
 int flib_weaponsetlist_to_ini(const char *filename, const flib_weaponsetlist *list) {
 	int result = -1;
-	if(!filename || !list) {
-		flib_log_e("null parameter in flib_weaponsetlist_to_ini");
-	} else {
+	if(!log_badargs_if2(filename==NULL, list==NULL)) {
 		flib_ini *ini = flib_ini_create(NULL);
 		if(ini && !flib_ini_create_section(ini, "General")) {
 			bool error = false;
@@ -236,9 +227,8 @@
 GENERATE_STATIC_LIST_DELETE(deleteWeaponset, flib_weaponset*)
 
 int flib_weaponsetlist_insert(flib_weaponsetlist *list, flib_weaponset *set, int pos) {
-	if(!list) {
-		flib_log_e("Invalid parameter in flib_weaponsetlist_insert");
-	} else if(!insertWeaponset(&list->weaponsets, &list->weaponsetCount, set, pos)) {
+	if(!log_badargs_if2(list==NULL, set==NULL)
+			&& !insertWeaponset(&list->weaponsets, &list->weaponsetCount, set, pos)) {
 		flib_weaponset_retain(set);
 		return 0;
 	}
@@ -246,9 +236,7 @@
 }
 
 int flib_weaponsetlist_delete(flib_weaponsetlist *list, int pos) {
-	if(!list) {
-		flib_log_e("Invalid parameter in flib_weaponsetlist_delete");
-	} else {
+	if(!log_badargs_if(list==NULL)) {
 		flib_weaponset *elem = list->weaponsets[pos];
 		if(!deleteWeaponset(&list->weaponsets, &list->weaponsetCount, pos)) {
 			flib_weaponset_release(elem);