more crashes caused by shipowner==NULL

This commit is contained in:
Enno Rehling 2007-02-04 13:30:06 +00:00
parent 8d5ee9c811
commit 8c82b2815e
6 changed files with 42 additions and 35 deletions

View File

@ -192,7 +192,7 @@ print_curses(FILE * F, const faction * viewer, const void * obj, typ_t typ)
unit * owner = shipowner(sh);
a = sh->attribs;
r = sh->region;
if(owner != NULL) {
if (owner != NULL) {
if (owner->faction == viewer){
self = 2;
} else { /* steht eine person der Partei auf dem Schiff? */

View File

@ -449,7 +449,7 @@ print_curses(FILE *F, const faction *viewer, const void * obj, typ_t typ, int in
unit * owner = shipowner(sh);
a = sh->attribs;
r = sh->region;
if((owner) != NULL){
if (owner) {
if (owner->faction == viewer){
self = 2;
} else { /* steht eine person der Partei auf dem Schiff? */

View File

@ -1102,7 +1102,6 @@ mayboard(const unit * u, const ship * sh)
unit *u2 = shipowner(sh);
return (!u2 || ucontact(u2, u) || alliedunit(u2, u->faction, HELP_GUARD));
}
int

View File

@ -652,8 +652,10 @@ ship_allowed(const struct ship * sh, const region * r)
if (is_freezing(u)) {
unit * captain = shipowner(sh);
ADDMSG(&captain->faction->msgs, msg_message("detectforbidden",
"unit region", u, r));
if (captain) {
ADDMSG(&captain->faction->msgs, msg_message("detectforbidden",
"unit region", u, r));
}
return false;
}

View File

@ -494,36 +494,42 @@ crew_skill(region * r, faction * f, ship * sh, skill_t sk)
static int
try_destruction(unit * u, unit * u2, const char *name, int skilldiff)
{
const char *destruction_success_msg = "%s wurde von %s zerstoert.";
const char *destruction_failed_msg = "%s konnte %s nicht zerstoeren.";
const char *destruction_detected_msg = "%s wurde beim Versuch, %s zu zerstoeren, entdeckt.";
const char *detect_failure_msg = "Es wurde versucht, %s zu zerstoeren.";
const char *object_destroyed_msg = "%s wurde zerstoert.";
const char *destruction_success_msg = "%s wurde von %s zerstoert.";
const char *destruction_failed_msg = "%s konnte %s nicht zerstoeren.";
const char *destruction_detected_msg = "%s wurde beim Versuch, %s zu zerstoeren, entdeckt.";
const char *detect_failure_msg = "Es wurde versucht, %s zu zerstoeren.";
const char *object_destroyed_msg = "%s wurde zerstoert.";
if (skilldiff == 0) {
/* tell the unit that the attempt failed: */
sprintf(buf, destruction_failed_msg, unitname(u), name);
addmessage(0, u->faction, buf, MSG_EVENT, ML_WARN);
/* tell the enemy about the attempt: */
sprintf(buf, detect_failure_msg, name);
addmessage(0, u2->faction, buf, MSG_EVENT, ML_IMPORTANT);
return 0;
}
if (skilldiff < 0) {
/* tell the unit that the attempt was detected: */
sprintf(buf, destruction_detected_msg, unitname(u), name);
addmessage(0, u->faction, buf, MSG_EVENT, ML_WARN);
/* tell the enemy whodunit: */
sprintf(buf, detect_failure_msg, unitname(u2), unitname(u), name);
addmessage(0, u2->faction, buf, MSG_EVENT, ML_IMPORTANT);
return 0;
}
/* tell the unit that the attempt succeeded */
sprintf(buf, destruction_success_msg, name, unitname(u));
addmessage(0, u->faction, buf, MSG_EVENT, ML_INFO);
sprintf(buf, object_destroyed_msg, name);
addmessage(0, u2->faction, buf, MSG_EVENT, ML_IMPORTANT);
return 1; /* success */
if (skilldiff == 0) {
/* tell the unit that the attempt failed: */
sprintf(buf, destruction_failed_msg, unitname(u), name);
addmessage(0, u->faction, buf, MSG_EVENT, ML_WARN);
/* tell the enemy about the attempt: */
if (u2) {
sprintf(buf, detect_failure_msg, name);
addmessage(0, u2->faction, buf, MSG_EVENT, ML_IMPORTANT);
}
return 0;
}
if (skilldiff < 0) {
/* tell the unit that the attempt was detected: */
sprintf(buf, destruction_detected_msg, unitname(u), name);
addmessage(0, u->faction, buf, MSG_EVENT, ML_WARN);
/* tell the enemy whodunit: */
if (u2) {
sprintf(buf, detect_failure_msg, unitname(u2), unitname(u), name);
addmessage(0, u2->faction, buf, MSG_EVENT, ML_IMPORTANT);
}
return 0;
}
/* tell the unit that the attempt succeeded */
sprintf(buf, destruction_success_msg, name, unitname(u));
addmessage(0, u->faction, buf, MSG_EVENT, ML_INFO);
if (u2) {
sprintf(buf, object_destroyed_msg, name);
addmessage(0, u2->faction, buf, MSG_EVENT, ML_IMPORTANT);
}
return 1; /* success */
}
static void

View File

@ -164,7 +164,7 @@ verify_owners(boolean bOnce)
}
if (u->ship) {
unit * bo = shipowner(u->ship);
if (!fval(bo, UFL_OWNER)) {
if (bo && !fval(bo, UFL_OWNER)) {
log_error(("[verify_owners] %u ist Besitzer von %s, hat aber UFL_OWNER nicht.\n", unitname(bo), shipname(u->ship)));
bFail = true;
if (bOnce) break;