投稿者 トピック: [patch] プレイヤーのパスワード保護を取り除く  (参照数 5716 回)

z9999+

  • 管理人
  • 急行
  • *
  • 投稿: 381
空のパスワードを入力することで、パスワード保護を取り除き、再び誰でも操作可能にします。OpenTTDなどと同じです。

simutransは、緑と赤で現在操作可能かどうかは表示してくれますが、「パスワード保護状態」は表示してくれないので、操作には注意が必要になります。

コード: [選択]
Index: gui/password_frame.cc
===================================================================
--- gui/password_frame.cc (リビジョン 4076)
+++ gui/password_frame.cc (作業コピー)
@@ -67,14 +67,18 @@
  */
 bool password_frame_t::action_triggered( gui_action_creator_t *komp, value_t p )
 {
- if(komp == &password  &&  p.i == 1) {
+ if(komp == &password  &&  (ibuf[0]!=0  ||  p.i == 1)) {
  // Enter-Key pressed
  // test for matching password to unlock
  SHA1 sha1;
- sha1.Input( password.get_text(), strlen( password.get_text() ) );
+ size_t len = strlen( password.get_text() );
+ sha1.Input( password.get_text(), len );
  uint8 hash[20];
  MEMZERO(hash);
- sha1.Result( hash );
+ // remove hash to re-open slot if password is empty
+ if(len>0) {
+ sha1.Result( hash );
+ }
  /* if current active player is player 1 and this is unlocked, he may reset passwords
  * otherwise you need the valid previous password
  */